Пример #1
0
 public void Shoot(bool state)
 {
     if (state)
     {
         weapon.Fire();
     }
     else
     {
         weapon.HaltFire();
     }
 }
Пример #2
0
    void Update()
    {
        if (status == Status.Disabled)
        {
            return;
        }
        if (status != Status.Firing)
        {
            weapon.HaltFire();
        }
        switch (status)
        {
        case Status.Hidden:
            if (retargetCurrentTime >= retargetTime)
            {
                if (CanSeePlayer())
                {
                    Deploy();
                }
                retargetCurrentTime -= retargetTime;
            }
            else
            {
                retargetCurrentTime += Time.deltaTime;
            }
            break;

        case Status.Deployed:
            if (retargetCurrentTime >= retargetTime)
            {
                if (CanSeePlayer())
                {
                    status = Status.Firing;
                }
                retargetCurrentTime -= retargetTime;
            }
            else
            {
                retargetCurrentTime += Time.deltaTime;
            }
            break;

        case Status.Firing:
            weapon.transform.LookAt(PlayerController.Instance.Position(), Vector3.up);
            weapon.Fire();
            if (retargetCurrentTime >= retargetTime)
            {
                if (!CanSeePlayer())
                {
                    status = Status.Deployed;
                }
                retargetCurrentTime -= retargetTime;
            }
            else
            {
                retargetCurrentTime += Time.deltaTime;
            }
            break;

        case Status.Shielding:
            if (shieldingId == -1)    //shield.IsOn() && !shield.IsEngaging())
            {
                shieldingId = LeanTween.delayedCall(1f, () => StopShielding()).id;
            }
            break;
        }
    }