Guest User

PlayerControllerRTS

a guest
May 17th, 2017
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. using UnityStandardAssets.Utility;
  5.  
  6. [RequireComponent(typeof (UnityEngine.AI.NavMeshAgent))]
  7. public class PlayerControllerRTS : uLink.MonoBehaviour {
  8. public UnityEngine.AI.NavMeshAgent agent { get; private set; } // the navmesh agent required for the path finding
  9.  
  10.  
  11.  
  12. public MobaStorm.PlayerState playerStatus = MobaStorm.PlayerState.idle;
  13. private MobaStorm.MouseState mouseState = MobaStorm.MouseState.server;
  14. private InputField inputFieldGameChat;
  15. //USED TO SEND THE TARGET NAME TO THE SERVER
  16. private GameObject targetObj;
  17.  
  18.  
  19. private Vector3 pointerPos;
  20.  
  21. public GameObject mouseMovePointerPrefab;
  22. private GameObject mouseMovePointer;
  23. private GameObject mouseProjector;
  24.  
  25.  
  26. private Animator animator;
  27.  
  28. //SCRIPTS ACCESED ON THIS CLASS
  29. private PlayerSpells playerSpellScript;
  30.  
  31. private Image healthCdImage;
  32. private Image ManaCdImage;
  33.  
  34. //private DmgDatabase dmgScript;
  35.  
  36. private Vector3 destinationPos;
  37.  
  38.  
  39. public LayerMask redMask;
  40. public LayerMask blueMask;
  41. public LayerMask floorMask;
  42.  
  43. public LayerMask mask;
  44.  
  45. private GamePanelUi gamePanelScript;
  46. [HideInInspector] public PlayerStats playerStScript;
  47.  
  48. //STORE THE INITIAL POSITION AND ROTATION OF THE PLAYER TO WARP THE AGENT WHEN THE PLAYER IS DEAD
  49. private Vector3 initialPos;
  50. private Quaternion initialRotation;
  51.  
  52. //USED TO SEND LOCK THE CAMERA TO THE CURRENT OWNER NETWORK PLAYER
  53. private GameObject cameraObj;
  54. Camera cam;
  55. private CustomCamera cameraScript;
  56.  
  57. //Handle particle creation
  58. //[HideInInspector] public ParticleManager particleScript;
  59.  
  60. private GameObject teleportParticle;
  61. private GameObject teleportObj;
  62. private Image mainPortrait;
  63. //VOID START
  64. void Start () {
  65.  
  66. mouseMovePointer = (GameObject)Instantiate(mouseMovePointerPrefab, Vector3.zero, Quaternion.identity);
  67. animator = GetComponent<Animator>();
  68. playerStScript = GetComponent<PlayerStats>();
  69.  
  70. //FIND THE InputFieldGameChat Object and get the InputField COMPONENT
  71. inputFieldGameChat = GameObject.Find("InputFieldGameChat").GetComponent<InputField>();
  72.  
  73.  
  74. if (uLink.Network.isServer)
  75. {
  76. playerSpellScript = transform.GetComponent<PlayerSpells>();
  77. agent = GetComponentInChildren<UnityEngine.AI.NavMeshAgent>();
  78.  
  79. agent.updateRotation = false;
  80. agent.updatePosition = true;
  81.  
  82. initialRotation = transform.rotation;
  83. initialPos = transform.position;
  84.  
  85.  
  86. }
  87.  
  88. }
  89.  
  90. void Update () {
  91. //If the game has ended do nothing!
  92. if (ScoreTable.instance.GameEnded == true)
  93. {
  94. animator.Stop();
  95. return;
  96. }
  97.  
  98. if (teleportObj)
  99. {
  100. teleportObj.transform.position = transform.position;
  101. }
  102.  
  103.  
  104. if (uLink.Network.isServer)
  105. {
  106. //DISABLE ANIMATOR COMPONENT IF THE PLAYER IS STUNNED
  107. if (playerStScript.stunObj && playerStScript.Health > 0)
  108. {
  109. if (uLink.Network.isServer)
  110. {
  111. agent.Stop();
  112. playerStatus = MobaStorm.PlayerState.idle;
  113. }
  114. animator.enabled = false;
  115. return;
  116. }
  117. else
  118. {
  119. animator.enabled = true;
  120. }
  121.  
  122. if (playerStScript.Health<=0)
  123. {
  124. playerStatus = MobaStorm.PlayerState.dead;
  125. }
  126.  
  127.  
  128. //SHITCH CASE TO CONTROLL ALL ACTIONS OF THE PLAYER
  129. switch (playerStatus)
  130. {
  131. case MobaStorm.PlayerState.idle:
  132.  
  133.  
  134. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.idle);
  135.  
  136. break;
  137. case MobaStorm.PlayerState.running:
  138. if (!playerStScript.charLocked && !playerStScript.abilityLocked)
  139. {
  140. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.running);
  141.  
  142. MoveOrChase();
  143.  
  144. if (!agent.pathPending)
  145. {
  146. if (agent.remainingDistance <= agent.stoppingDistance)
  147. {
  148. if (!agent.hasPath || agent.velocity.sqrMagnitude == 0f)
  149. {
  150. playerStatus = MobaStorm.PlayerState.idle;
  151. }
  152. }
  153. }
  154. }
  155. break;
  156.  
  157. case MobaStorm.PlayerState.chasing:
  158.  
  159. break;
  160. case MobaStorm.PlayerState.attackingBasic:
  161.  
  162. CalculateAttack(playerStScript.stats.basic.weaponType, MobaStorm.PlayerState.attackingBasic, playerStScript.stats.basic.rangue, playerStScript.stats.basic.cdr, playerStScript.stats.basic.cdrTStamp,
  163. playerStScript.stats.basic.manaCost);
  164.  
  165. break;
  166. case MobaStorm.PlayerState.attackingQ:
  167.  
  168. CalculateAttack(playerStScript.stats.q.weaponType, MobaStorm.PlayerState.attackingQ, playerStScript.stats.q.rangue, playerStScript.stats.q.cdr, playerStScript.stats.q.cdrTStamp,
  169. playerStScript.stats.q.manaCost);
  170.  
  171. break;
  172.  
  173. case MobaStorm.PlayerState.attackingW:
  174.  
  175.  
  176. CalculateAttack(playerStScript.stats.w.weaponType, MobaStorm.PlayerState.attackingW, playerStScript.stats.w.rangue, playerStScript.stats.w.cdr, playerStScript.stats.w.cdrTStamp,
  177. playerStScript.stats.w.manaCost);
  178.  
  179.  
  180. break;
  181.  
  182. case MobaStorm.PlayerState.attackingE:
  183.  
  184.  
  185. CalculateAttack(playerStScript.stats.e.weaponType, MobaStorm.PlayerState.attackingE, playerStScript.stats.e.rangue, playerStScript.stats.e.cdr, playerStScript.stats.e.cdrTStamp,
  186. playerStScript.stats.e.manaCost);
  187.  
  188. break;
  189. case MobaStorm.PlayerState.attackingR:
  190.  
  191. CalculateAttack(playerStScript.stats.r.weaponType, MobaStorm.PlayerState.attackingR, playerStScript.stats.r.rangue, playerStScript.stats.r.cdr, playerStScript.stats.r.cdrTStamp,
  192. playerStScript.stats.r.manaCost);
  193. break;
  194.  
  195. case MobaStorm.PlayerState.dead:
  196.  
  197.  
  198. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.dead);
  199. agent.Stop();
  200. break;
  201.  
  202. case MobaStorm.PlayerState.recall:
  203.  
  204. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.recall);
  205.  
  206. break;
  207.  
  208. case MobaStorm.PlayerState.emote:
  209.  
  210. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.emote);
  211. agent.Stop();
  212. break;
  213.  
  214. }
  215. }
  216. }
  217.  
  218.  
  219. public void OnGUI () {
  220.  
  221. RaycastHit hit;
  222. if (!uLink.Network.isServer)
  223. {
  224. if (playerStScript.PlayerTeam == "red")
  225. {
  226. mask = redMask;
  227. }
  228. else
  229. {
  230. mask = blueMask;
  231. }
  232. }
  233.  
  234. }
  235.  
  236.  
  237.  
  238. //ADD A LEVEL TO THE PLAYER SPELL AND SEND A RPC TO THE CLIENTS WITH THE NEW VALUE
  239. [RPC]
  240. private void UpgradeAbilityServer(MobaStorm.PlayerState type, bool levelUpAbility)
  241. {
  242.  
  243. switch (type)
  244. {
  245. case MobaStorm.PlayerState.attackingBasic:
  246. if (playerStScript.stats.basic.weaponLvl < 1 && levelUpAbility)
  247. playerStScript.stats.basic.weaponLvl ++;
  248.  
  249. networkView.RPC("UpgradeAbilityClient", uLink.RPCMode.Owner, MobaStorm.PlayerState.attackingBasic, playerStScript.stats.basic.cdr,
  250. playerStScript.stats.basic.ad, playerStScript.stats.basic.ap, playerStScript.stats.basic.weaponLvl);
  251.  
  252.  
  253. break;
  254. case MobaStorm.PlayerState.attackingQ:
  255. if (playerStScript.stats.q.weaponLvl<1 && levelUpAbility)
  256. playerStScript.stats.q.weaponLvl ++;
  257.  
  258. networkView.RPC("UpgradeAbilityClient", uLink.RPCMode.Owner, MobaStorm.PlayerState.attackingQ, playerStScript.stats.q.cdr,
  259. playerStScript.stats.q.ad, playerStScript.stats.q.ap, playerStScript.stats.q.weaponLvl);
  260. break;
  261. case MobaStorm.PlayerState.attackingW:
  262. if (playerStScript.stats.w.weaponLvl<1 && levelUpAbility)
  263. playerStScript.stats.w.weaponLvl ++;
  264.  
  265. networkView.RPC("UpgradeAbilityClient", uLink.RPCMode.Owner, MobaStorm.PlayerState.attackingW, playerStScript.stats.w.cdr,
  266. playerStScript.stats.w.ad, playerStScript.stats.w.ap, playerStScript.stats.w.weaponLvl);
  267. break;
  268. case MobaStorm.PlayerState.attackingE:
  269. if (playerStScript.stats.e.weaponLvl<1 && levelUpAbility)
  270. playerStScript.stats.e.weaponLvl ++;
  271.  
  272. networkView.RPC("UpgradeAbilityClient", uLink.RPCMode.Owner, MobaStorm.PlayerState.attackingE, playerStScript.stats.e.cdr,
  273. playerStScript.stats.e.ad, playerStScript.stats.e.ap, playerStScript.stats.e.weaponLvl);
  274. break;
  275. case MobaStorm.PlayerState.attackingR:
  276. if (playerStScript.stats.r.weaponLvl <1 && levelUpAbility)
  277. playerStScript.stats.r.weaponLvl ++;
  278.  
  279. networkView.RPC("UpgradeAbilityClient", uLink.RPCMode.Owner, MobaStorm.PlayerState.attackingR, playerStScript.stats.r.cdr,
  280. playerStScript.stats.r.ad, playerStScript.stats.r.ap, playerStScript.stats.r.weaponLvl);
  281. break;
  282. }
  283.  
  284. }
  285.  
  286.  
  287.  
  288. //THIS METHOD IS USED TO CALCULATE THE ATTACK COMMANDS OF THE PLAYER
  289. //AND CHANGE THE ANIMATION PARAMETERS TO THE ABILITY USED
  290. void CalculateAttack(DmgDataclass.type abilityType, MobaStorm.PlayerState StateAttacking, float range,float cdr_, float cdr_timestamp, float ManaCost)
  291. {
  292.  
  293. switch (abilityType)
  294. {
  295.  
  296. case DmgDataclass.type.lockedShot_rangue:
  297.  
  298. if (!playerStScript.charLocked && !playerStScript.abilityLocked)
  299. {
  300. if (targetObj)
  301. {
  302. if (targetObj.GetComponent<PlayerStats>().Health <=0)
  303. {
  304. targetObj = null;
  305. playerStatus = MobaStorm.PlayerState.idle;
  306. agent.Stop();
  307. return;
  308. }
  309. }
  310. else
  311. {
  312. playerStatus = MobaStorm.PlayerState.idle;
  313. }
  314. if (Vector3.Distance(targetObj.transform.position,this.transform.position) < range)
  315. {
  316. agent.Stop();
  317. if (cdr_timestamp <= Time.time)
  318. {
  319.  
  320. //DRAIN MANA FROM THE PLAYER
  321. MobaStorm.UpdateMana(this.networkView, playerStScript.Mana, playerStScript.ManaMax, playerStScript.HealthRegeneration, ManaCost);
  322.  
  323. //ROTATE TO FACE THE TARGET
  324. Vector3 fromPosition = transform.position;
  325. fromPosition.y = 0;
  326. Vector3 toPosition = targetObj.transform.position;
  327. toPosition.y = 0;
  328. Quaternion targetRotation = Quaternion.LookRotation (toPosition - fromPosition);
  329. transform.rotation = targetRotation;
  330. UpdateCdr( StateAttacking, cdr_);
  331. cdr_timestamp = Time.time + cdr_;
  332. playerStScript.charLocked = true;
  333. playerStScript.abilityLocked = true;
  334. animator.SetInteger("AnimType", (int)StateAttacking);
  335. playerSpellScript.AttackDestination = targetObj.transform.position;
  336. playerSpellScript.target_obj = targetObj;
  337.  
  338.  
  339. }
  340. else
  341. {
  342. //ROTATE TO FACE THE TARGET
  343. Vector3 fromPosition = transform.position;
  344. fromPosition.y = 0;
  345. Vector3 toPosition = targetObj.transform.position;
  346. toPosition.y = 0;
  347. Quaternion targetRotation = Quaternion.LookRotation (toPosition - fromPosition);
  348.  
  349. transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, 1);
  350. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.idle);
  351. }
  352.  
  353. }
  354. else
  355. {
  356. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.running);
  357. MoveOrChase();
  358. }
  359.  
  360.  
  361. }
  362.  
  363.  
  364.  
  365. break;
  366. case DmgDataclass.type.skillShot_front:
  367. if (!playerStScript.charLocked && !playerStScript.abilityLocked)
  368. {
  369.  
  370. if (Vector3.Distance(destinationPos,this.transform.position) < range)
  371. {
  372. //ROTATE TO FACE THE TARGET
  373. Vector3 fromPosition = transform.position;
  374. fromPosition.y = 0;
  375. Vector3 toPosition = destinationPos;
  376. toPosition.y = 0;
  377. Quaternion targetRotation = Quaternion.LookRotation (toPosition - fromPosition);
  378. agent.Stop();
  379. if (cdr_timestamp <= Time.time && playerStScript.Mana >= ManaCost)
  380. {
  381. //DRAIN MANA FROM THE PLAYER
  382. MobaStorm.UpdateMana(this.networkView, playerStScript.Mana, playerStScript.ManaMax,playerStScript.HealthRegeneration, ManaCost);
  383. transform.rotation = targetRotation;
  384. UpdateCdr( StateAttacking, cdr_);
  385. cdr_timestamp = Time.time + cdr_;
  386. playerStScript.charLocked = true;
  387. playerStScript.abilityLocked = true;
  388. animator.SetInteger("AnimType", (int)StateAttacking);
  389. playerSpellScript.AttackDestination = destinationPos;
  390. playerSpellScript.target_obj = targetObj;
  391.  
  392.  
  393. }
  394. else
  395. {
  396.  
  397. transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, 1);
  398. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.idle);
  399. }
  400.  
  401. }
  402. else
  403. {
  404. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.running);
  405. MoveOrChase();
  406. }
  407.  
  408.  
  409. }
  410.  
  411. break;
  412. case DmgDataclass.type.skillShot_floor:
  413.  
  414. if (!playerStScript.charLocked && !playerStScript.abilityLocked)
  415. {
  416. if (Vector3.Distance(destinationPos,this.transform.position) < range)
  417. {
  418. //ROTATE TO FACE THE TARGET
  419. Vector3 fromPosition = transform.position;
  420. fromPosition.y = 0;
  421. Vector3 toPosition = destinationPos;
  422. toPosition.y = 0;
  423. Quaternion targetRotation = Quaternion.LookRotation (toPosition - fromPosition);
  424. agent.Stop();
  425. if (cdr_timestamp <= Time.time && playerStScript.Mana >= ManaCost)
  426. {
  427. //DRAIN MANA FROM THE PLAYER
  428. MobaStorm.UpdateMana(this.networkView, playerStScript.Mana, playerStScript.ManaMax,playerStScript.HealthRegeneration, ManaCost);
  429.  
  430.  
  431. transform.rotation = targetRotation;
  432. UpdateCdr( StateAttacking, cdr_);
  433. cdr_timestamp = Time.time + cdr_;
  434. playerStScript.charLocked = true;
  435. playerStScript.abilityLocked = true;
  436. animator.SetInteger("AnimType", (int)StateAttacking);
  437. playerSpellScript.AttackDestination = destinationPos;
  438. playerSpellScript.target_obj = targetObj;
  439.  
  440. }
  441. else
  442. {
  443.  
  444. transform.rotation = Quaternion.Lerp (transform.rotation, targetRotation, 1);
  445. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.idle);
  446. }
  447.  
  448. }
  449. else
  450. {
  451. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.running);
  452. MoveOrChase();
  453. }
  454.  
  455.  
  456. }
  457.  
  458. break;
  459. case DmgDataclass.type.aoe_instant:
  460.  
  461. if (cdr_timestamp <= Time.time && playerStScript.Mana >= ManaCost)
  462. {
  463. //DRAIN MANA FROM THE PLAYER
  464. MobaStorm.UpdateMana(this.networkView, playerStScript.Mana, playerStScript.ManaMax,playerStScript.HealthRegeneration, ManaCost);
  465.  
  466. UpdateCdr( StateAttacking, cdr_);
  467. cdr_timestamp = Time.time + cdr_;
  468. playerSpellScript.Attacking((int)StateAttacking);
  469.  
  470. }
  471.  
  472. break;
  473.  
  474.  
  475. }
  476. }
  477.  
  478. //MOVE OR CHASE METHOD
  479. //USED TO CONTROL THE AGENT COMPONENT ATTACHED ON THE PLAYER
  480. public void MoveOrChase()
  481. {
  482. if (playerStScript.Health<=0)
  483. {
  484. agent.Stop();
  485. return;
  486. }
  487.  
  488. agent.Resume();
  489. float finalSpeed = playerStScript.Speed + ((playerStScript.Speed * playerStScript.speedAdd) / 100);
  490. agent.speed = finalSpeed;
  491.  
  492.  
  493. if (targetObj)
  494. {
  495. agent.SetDestination(targetObj.transform.position);
  496. if (agent.velocity.normalized != Vector3.zero)
  497. transform.rotation = Quaternion.LookRotation(agent.velocity.normalized);
  498. }
  499. else
  500. {
  501. if (agent.velocity.normalized != Vector3.zero)
  502. transform.rotation = Quaternion.LookRotation(agent.velocity.normalized);
  503. }
  504.  
  505.  
  506. }
  507.  
  508. //CALLED FROM THE ANIMATION EVENTS OF EACH PLAYER ANIMATION TO UNLOCK THE PLAYER
  509. //WHEN THE ABILITY ANIMATION IS ENDING
  510. void ExitAnim()
  511. {
  512. playerStScript.charLocked = false;
  513.  
  514. }
  515.  
  516.  
  517. //THIS METHOD IS RUNNING ON THE SERVER
  518. //CALCULATE IF THE PLAYER WILL MOVE TO ANY LOCATIO OR ATTACK AN ENEMY
  519. [RPC]
  520. void SendAttackToServer (Vector3 newPosition, MobaStorm.PlayerState state, string targetName)
  521. {
  522. //Debug.Log("Attack Sent");
  523. if (!playerStScript.charLocked && !playerStScript.abilityLocked && playerStScript.Health > 0)
  524. {
  525. if (teleportObj)
  526. {
  527. Destroy(teleportObj);
  528. networkView.RPC("ShowTeleportParticle", uLink.RPCMode.Others, false);
  529. }
  530.  
  531. playerStatus = state;
  532.  
  533. if (playerStatus == MobaStorm.PlayerState.running) {
  534. if (targetName == "")
  535. {
  536. targetObj = null;
  537. agent.SetDestination(newPosition);
  538. playerStatus = MobaStorm.PlayerState.running;
  539. }
  540. else
  541. {
  542.  
  543. targetObj = GameObject.Find(targetName);
  544. playerStatus = MobaStorm.PlayerState.attackingBasic;
  545. }
  546. }
  547.  
  548. if (playerStatus == MobaStorm.PlayerState.attackingQ && targetName != "NoTarget") {
  549. agent.SetDestination(newPosition);
  550. destinationPos = newPosition;
  551. }
  552. if (playerStatus == MobaStorm.PlayerState.attackingW && targetName != "NoTarget") {
  553. agent.SetDestination(newPosition);
  554. destinationPos = newPosition;
  555. }
  556.  
  557. if (playerStatus == MobaStorm.PlayerState.attackingE && targetName != "NoTarget") {
  558. agent.SetDestination(newPosition);
  559. destinationPos = newPosition;
  560. }
  561.  
  562. if (playerStatus == MobaStorm.PlayerState.attackingR && targetName != "NoTarget") {
  563. agent.SetDestination(newPosition);
  564. destinationPos = newPosition;
  565.  
  566. }
  567.  
  568. }
  569. }
  570.  
  571. //THIS METHOD IS USED TO UPDATE THE CURRENT CDR OF THE SERVER TO THE OWNER PLAYER
  572. [RPC]
  573. void UpdateCdr (MobaStorm.PlayerState state, float cdrFromServer)
  574. {
  575. if (uLink.Network.isServer)
  576. {
  577. networkView.RPC("UpdateCdr", uLink.RPCMode.Owner, state, cdrFromServer);
  578. }
  579. switch (state)
  580. {
  581. case MobaStorm.PlayerState.attackingBasic:
  582. playerStScript.stats.basic.cdr = cdrFromServer;
  583. playerStScript.stats.basic.cdrTStamp = Time.time + playerStScript.stats.basic.cdr;
  584.  
  585. break;
  586.  
  587. case MobaStorm.PlayerState.attackingQ:
  588. playerStScript.stats.q.cdr = cdrFromServer;
  589. playerStScript.stats.q.cdrTStamp = Time.time + playerStScript.stats.q.cdr;
  590.  
  591. break;
  592.  
  593. case MobaStorm.PlayerState.attackingW:
  594. playerStScript.stats.w.cdr = cdrFromServer;
  595. playerStScript.stats.w.cdrTStamp = Time.time + playerStScript.stats.w.cdr;
  596.  
  597. break;
  598.  
  599. case MobaStorm.PlayerState.attackingE:
  600. playerStScript.stats.e.cdr = cdrFromServer;
  601. playerStScript.stats.e.cdrTStamp = Time.time + playerStScript.stats.e.cdr;
  602.  
  603. break;
  604.  
  605. case MobaStorm.PlayerState.attackingR:
  606. playerStScript.stats.r.cdr = cdrFromServer;
  607. playerStScript.stats.r.cdrTStamp = Time.time + playerStScript.stats.r.cdr;
  608.  
  609. break;
  610. }
  611. }
  612.  
  613. //RECALL METHOD
  614. public void RecallBase()
  615. {
  616. networkView.RPC("RecallBaseRPC", uLink.RPCMode.Server);
  617. }
  618.  
  619.  
  620. [RPC]
  621. public IEnumerator RecallBaseRPC()
  622. {
  623.  
  624. if (!playerStScript.abilityLocked && !playerStScript.charLocked && !teleportObj)
  625. {
  626.  
  627. teleportObj = Instantiate(teleportParticle, new Vector3(transform.position.x, 0.1f, transform.position.z), Quaternion.Euler(-90, 0, 0)) as GameObject;
  628. networkView.RPC("ShowTeleportParticle", uLink.RPCMode.Others, true);
  629. playerStatus = MobaStorm.PlayerState.recall;
  630. agent.Stop();
  631. networkView.RPC("RecallBaseRPC", uLink.RPCMode.Others);
  632. //animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.idle);
  633.  
  634. yield return new WaitForSeconds(4f);
  635.  
  636. if (teleportObj)
  637. {
  638. Destroy(teleportObj);
  639. networkView.RPC("ShowTeleportParticle", uLink.RPCMode.Others, false);
  640. playerStatus = MobaStorm.PlayerState.idle;
  641. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.idle);
  642. agent.Warp(initialPos);
  643. transform.rotation = initialRotation;
  644. agent.ResetPath();
  645. }
  646. }
  647.  
  648. }
  649.  
  650. [RPC]
  651. public IEnumerator ImDead()
  652. {
  653.  
  654. playerStatus = MobaStorm.PlayerState.dead;
  655. //Transform trigger = transform.FindChild("Trigger");
  656. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.dead);
  657. agent.enabled = true;
  658.  
  659. yield return new WaitForSeconds(playerStScript.RespawnTime);
  660.  
  661.  
  662. agent.enabled = true;
  663. agent.Warp(initialPos);
  664. Respawn();
  665. playerStScript.abilityLocked = false;
  666. playerStScript.charLocked = false;
  667. targetObj = null;
  668. playerStatus = MobaStorm.PlayerState.idle;
  669. animator.SetInteger("AnimType", (int)MobaStorm.PlayerState.idle);
  670. transform.rotation = initialRotation;
  671.  
  672. }
  673.  
  674. [RPC]
  675. public void Respawn ()
  676. {
  677. playerStScript.SetMaxHealth(playerStScript.HealthMax, playerStScript.HealthMax);
  678. playerStScript.SetMaxMana(playerStScript.ManaMax, playerStScript.ManaMax);
  679. playerStScript.destroyed = false;
  680. playerStScript.UpdateStatsOnClients();
  681.  
  682.  
  683. }
  684.  
  685. [RPC]
  686. public void ShowTeleportParticle (bool create)
  687. {
  688.  
  689.  
  690. }
  691.  
  692. [RPC]
  693. void ShowLvlUpParticle ()
  694. {
  695.  
  696.  
  697.  
  698. }
  699.  
  700.  
  701.  
  702.  
  703. }
RAW Paste Data