Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking;
- public class SetupLocalPlayer : NetworkBehaviour {
- Quaternion rotation;
- Rigidbody rb;
- NetworkAnimator anim;
- public float speed = 0.1f;
- public float startTimeBtwAttack = 2;
- public float startTImeBtwAttack3;
- public float startTimeBtwAttack4;
- public float sphereRadius = 5f;
- public float cleaveDamage = 10f;
- public float whirlwindDamage = 20f;
- public float hamstringDamage = 5f;
- [SyncVar]
- private float dmgAmount;
- private float timeBtwAttack;
- private float timeBtwAttack3;
- private float timeBtwAttack4;
- private float speedTimer;
- // Use this for initialization
- void Start () {
- anim = GetComponentInChildren<NetworkAnimator>();
- if (isLocalPlayer)
- {
- GetComponent<BobControls>().enabled = true;
- WowCamera.target = this.gameObject.transform;
- }
- else
- {
- GetComponent<BobControls>().enabled = false;
- }
- }
- // Update is called once per frame
- void Update () {
- CheckAbilityOne();
- CheckAbilityTwo();
- CheckAbilityFour();
- }
- [Command]
- public void CmdUpdateHealth(float health)
- {
- UpdateHealth(health);
- }
- void UpdateHealth(float hp)
- {
- Debug.Log("hersky fersky new hp " + hp);
- }
- private void CheckAbilityOne()
- {
- if (timeBtwAttack <= 0)
- {
- if (Input.GetKeyDown(KeyCode.Alpha1))
- {
- timeBtwAttack = startTimeBtwAttack;
- anim.SetTrigger("Cleave");
- dmgAmount = cleaveDamage;
- Collider[] hits = Physics.OverlapSphere(transform.position, sphereRadius);
- foreach (Collider hit in hits)
- {
- if (!isLocalPlayer)
- {
- Debug.Log(hit.name);
- if (hit.tag == "Player")
- {
- print("hit " + hit.gameObject); // <-----------------
- Damage(hit.transform);
- }
- }
- }
- }
- }
- }
- private void CheckAbilityTwo()
- {
- if (Input.GetKeyDown(KeyCode.Alpha2))
- {
- anim.SetTrigger("Hamstring");
- }
- }
- private void CheckAbilityFour()
- {
- //if (timeBtwAttack4 <= 0)
- //{
- // if (Input.GetKeyDown(KeyCode.Alpha4))
- // {
- // timeBtwAttack4 = startTimeBtwAttack4;
- // anim.SetTrigger("Whirlwind");
- // dmgAmount = whirlwindDamage;
- // Collider[] hits = Physics.OverlapSphere(transform.position, sphereRadius);
- // foreach (Collider hit in hits)
- // {
- // if (hit.tag == "Player")
- // {
- // print("hit " + hit.gameObject);
- // Damage(hit.transform);
- // }
- // }
- // }
- //}
- //else
- //{
- // timeBtwAttack4 -= Time.deltaTime;
- //}
- }
- void Damage(Transform enemy)
- {
- Enemy e = enemy.GetComponent<Enemy>();
- if (e != null)
- {
- e.TakeDamage(dmgAmount);
- }
- else
- {
- Debug.Log("Error taking damage.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement