private void UpdateInitDataPlayers(string sPrefabPath, DmgDataclass.type bType, DmgDataclass.type qType, DmgDataclass.type wType, DmgDataclass.type eType, DmgDataclass.type rType) { stats.prefabPath = sPrefabPath; stats.basic.weaponType = bType; stats.q.weaponType = qType; stats.w.weaponType = wType; stats.e.weaponType = eType; stats.r.weaponType = rType; }
//THIS METHOD IS USED TO CALCULATE THE ATTACK COMMANDS OF THE PLAYER //AND CHANGE THE ANIMATION PARAMETERS TO THE ABILITY USED void CalculateAttack(DmgDataclass.type abilityType, PlayerState StateAttacking, float range, float cdr_, float cdr_timestamp, float manaCost) { switch (abilityType) { case DmgDataclass.type.lockedShot_rangue: if (!playerStScript.charLocked && !playerStScript.abilityLocked) { if (targetObj) { if (targetObj.GetComponent <PlayerStats>().myHealth <= 0) { targetObj = null; playerStatus = PlayerState.idle; return; } } else { playerStatus = PlayerState.idle; } if (Vector3.Distance(targetObj.transform.position, this.transform.position) < range) { agent.Stop(); if (cdr_timestamp <= Time.time) { //DRAIN MANA FROM THE PLAYER playerStScript.mana = playerStScript.mana - manaCost; playerStScript.UpdateManaToClients(); //ROTATE TO FACE THE TARGET Vector3 fromPosition = transform.position; fromPosition.y = 0; Vector3 toPosition = targetObj.transform.position; toPosition.y = 0; Quaternion targetRotation = Quaternion.LookRotation(toPosition - fromPosition); transform.rotation = targetRotation; UpdateCdr(StateAttacking, cdr_); cdr_timestamp = Time.time + cdr_; playerStScript.charLocked = true; playerStScript.abilityLocked = true; animator.SetInteger("AnimType", (int)StateAttacking); playerSpellScript.AttackDestination = targetObj.transform.position; playerSpellScript.target_obj = targetObj; } else { //ROTATE TO FACE THE TARGET Vector3 fromPosition = transform.position; fromPosition.y = 0; Vector3 toPosition = targetObj.transform.position; toPosition.y = 0; Quaternion targetRotation = Quaternion.LookRotation(toPosition - fromPosition); transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, 1); animator.SetInteger("AnimType", (int)PlayerState.idle); } } else { animator.SetInteger("AnimType", (int)PlayerState.running); MoveOrChase(); } } break; case DmgDataclass.type.skillShot_front: if (!playerStScript.charLocked && !playerStScript.abilityLocked) { if (Vector3.Distance(destinationPos, this.transform.position) < range) { //ROTATE TO FACE THE TARGET Vector3 fromPosition = transform.position; fromPosition.y = 0; Vector3 toPosition = destinationPos; toPosition.y = 0; Quaternion targetRotation = Quaternion.LookRotation(toPosition - fromPosition); agent.Stop(); if (cdr_timestamp <= Time.time && playerStScript.mana >= manaCost) { //DRAIN MANA FROM THE PLAYER playerStScript.mana = playerStScript.mana - manaCost; playerStScript.UpdateManaToClients(); transform.rotation = targetRotation; UpdateCdr(StateAttacking, cdr_); cdr_timestamp = Time.time + cdr_; playerStScript.charLocked = true; playerStScript.abilityLocked = true; animator.SetInteger("AnimType", (int)StateAttacking); playerSpellScript.AttackDestination = destinationPos; playerSpellScript.target_obj = targetObj; } else { transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, 1); animator.SetInteger("AnimType", (int)PlayerState.idle); } } else { animator.SetInteger("AnimType", (int)PlayerState.running); MoveOrChase(); } } break; case DmgDataclass.type.skillShot_floor: if (!playerStScript.charLocked && !playerStScript.abilityLocked) { if (Vector3.Distance(destinationPos, this.transform.position) < range) { //ROTATE TO FACE THE TARGET Vector3 fromPosition = transform.position; fromPosition.y = 0; Vector3 toPosition = destinationPos; toPosition.y = 0; Quaternion targetRotation = Quaternion.LookRotation(toPosition - fromPosition); agent.Stop(); if (cdr_timestamp <= Time.time && playerStScript.mana >= manaCost) { //DRAIN MANA FROM THE PLAYER playerStScript.mana = playerStScript.mana - manaCost; playerStScript.UpdateManaToClients(); transform.rotation = targetRotation; UpdateCdr(StateAttacking, cdr_); cdr_timestamp = Time.time + cdr_; playerStScript.charLocked = true; playerStScript.abilityLocked = true; animator.SetInteger("AnimType", (int)StateAttacking); playerSpellScript.AttackDestination = destinationPos; playerSpellScript.target_obj = targetObj; } else { transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, 1); animator.SetInteger("AnimType", (int)PlayerState.idle); } } else { animator.SetInteger("AnimType", (int)PlayerState.running); MoveOrChase(); } } break; case DmgDataclass.type.aoe_instant: if (cdr_timestamp <= Time.time && playerStScript.mana >= manaCost) { //DRAIN MANA FROM THE PLAYER playerStScript.mana = playerStScript.mana - manaCost; playerStScript.UpdateManaToClients(); UpdateCdr(StateAttacking, cdr_); cdr_timestamp = Time.time + cdr_; playerSpellScript.Attacking((int)StateAttacking); } break; } }
//USED TO GENERATE CUSTOM GIZMOS FOR EACH PLAYER OR ABILITY USED void CalculateProjectors(DmgDataclass.type abilityType, string ProjectPrefab, PlayerState StateAttacking) { RaycastHit hit; switch (abilityType) { case DmgDataclass.type.lockedShot_rangue: break; case DmgDataclass.type.skillShot_front: if (ProjectPrefab == "") { if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, floorMask)) { networkView.RPC("SendAttackToServer", uLink.RPCMode.Server, hit.point, StateAttacking, ""); } } else { if (!mouseProjector) { mouseProjector = Instantiate(Resources.Load(ProjectPrefab, typeof(GameObject))) as GameObject; } if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, floorMask)) { Vector3 planePos = hit.point; planePos.y = transform.position.y; mouseProjector.transform.LookAt(planePos); mouseProjector.transform.position = transform.position; if (Input.GetMouseButtonDown(0)) { mouseState = MouseState.idle; networkView.RPC("SendAttackToServer", uLink.RPCMode.Server, hit.point, StateAttacking, ""); Destroy(mouseProjector); } if (Input.GetMouseButtonDown(1)) { mouseState = MouseState.idle; Destroy(mouseProjector); } } } break; case DmgDataclass.type.skillShot_floor: if (ProjectPrefab == "") { if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, floorMask)) { networkView.RPC("SendAttackToServer", uLink.RPCMode.Server, hit.point, StateAttacking, ""); } } else { if (!mouseProjector) { Debug.Log("loading Prefab"); mouseProjector = Instantiate(Resources.Load(ProjectPrefab, typeof(GameObject))) as GameObject; } if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, floorMask)) { Vector3 planePos = hit.point; planePos.y = planePos.y + 0.03f; mouseProjector.transform.position = planePos; if (Input.GetMouseButtonDown(0)) { mouseState = MouseState.idle; Destroy(mouseProjector); networkView.RPC("SendAttackToServer", uLink.RPCMode.Server, hit.point, StateAttacking, ""); } if (Input.GetMouseButtonDown(1)) { mouseState = MouseState.idle; Destroy(mouseProjector); } } } break; case DmgDataclass.type.aoe_instant: networkView.RPC("SendAttackToServer", uLink.RPCMode.Server, Vector3.zero, StateAttacking, "NoTarget"); break; } }