public void Activate()
    {
        bikeBrainMP bb = owner.GetComponent <bikeBrainMP>();

        bb.health = bb.totalHealth;
        bb.UpdateHealth();
    }
Exemple #2
0
    void Update()
    {
        if (PhotonNetwork.IsMasterClient)
        {
            closestPlayer = GetClosestPlayer();

            if (!isDead && !closestPlayer.isDead)
            {
                Vector3 direction = closestPlayer.transform.position - transform.position;
                bool    hit       = Physics.Raycast(transform.position, direction, direction.magnitude, layerMask);
                rangeToPlayer = Vector3.Distance(transform.position, closestPlayer.transform.position);
                float angleTo = Mathf.Acos(Vector3.Dot(direction.normalized, transform.forward)) * Mathf.Rad2Deg;

                if (!hit && rangeToPlayer < sightRange && angleTo < attackAngle)
                {
                    Debug.Log("Can see");
                    canSeePlayer = true;
                }

                if (canSeePlayer && angleTo < attackAngle)
                {
                    head.transform.LookAt(closestPlayer.transform);
                    if (rangeToPlayer <= meleeRange && !attackCoroutineStarted)
                    {
                        StartCoroutine("Attack");
                    }
                }
            }
        }
    }
Exemple #3
0
    public bikeBrainMP GetClosestPlayer()
    {
        float       closest       = Mathf.Infinity;
        bikeBrainMP closestPlayer = null;

        foreach (bikeBrainMP player in players)
        {
            if (!player.isDead)
            {
                float distance = Vector3.Distance(player.transform.position, transform.position);

                if (distance < closest)
                {
                    closest       = distance;
                    closestPlayer = player;
                }
            }
        }

        return(closestPlayer);
    }
 private void Start()
 {
     menu       = transform.Find("UI/Navigation").gameObject;
     player     = GetComponent <bikeBrainMP>();
     flavorText = transform.Find("UI/Flavor").gameObject.GetComponent <TextMeshProUGUI>();
 }
Exemple #5
0
    public void Activate()
    {
        bikeBrainMP bb = owner.GetComponent <bikeBrainMP>();

        bb.SetBoost(true, 10);
    }