コード例 #1
0
ファイル: EnemyVision.cs プロジェクト: PaulMilla/2Dcapstone
 void Start()
 {
     Enemy = GetComponentInParent<EnemyGuard>();
     PlayerMovement.Instance.RewindEnd += () => {
         target = null;
     };
 }
コード例 #2
0
ファイル: RewindManager.cs プロジェクト: PaulMilla/2Dcapstone
 // Use this for initialization
 void Start()
 {
     guard = GetComponent<EnemyGuard>();
     recordedEvents = new Stack<Position>();
     isRewinding = false;
     PlayerMovement.Instance.RewindBegin += () => {
         isRewinding = true;
         guard.preRewind();
     };
     PlayerMovement.Instance.RewindEnd += () => {
         isRewinding = false;
         guard.postRewind();
     };
 }
コード例 #3
0
ファイル: EnemyCam.cs プロジェクト: cebollinos11/gamedev
    // Update is called once per frame
    void Update()
    {
        FOVControl();
        if (base.state != Enemy.enemyState.inactive)
        {
            int seeState = 0;
            foreach (FOV fov in fovs)
            {
                seeState = fov.canSeePlayer();

                if (seeState != 0)
                {
                    break;
                }
            }

            if (seeState != 0)
            {
                Debug.Log("cam: player spotted!");
                if (!alertSent)
                {
                    EnemyGuard[] enemies = GameObject.FindObjectsOfType<EnemyGuard>();

                    foreach (EnemyGuard enemy in enemies)
                    {
                        if (nearestEnemy == null)
                        {
                            nearestEnemy = enemy;
                        }
                        else if (Vector3.Distance(transform.position, enemy.transform.position) < Vector3.Distance(transform.position, nearestEnemy.transform.position))
                        {
                            nearestEnemy = enemy;
                        }
                    }

                    if (nearestEnemy != null)
                    {
                        nearestEnemy.investigate = true;
                        nearestEnemy.investigatePos = player.transform.position;
                    }

                    alertSent = true;
                }
            }
            else
            {
                if (alertSent) alertSent = false;

                if(nearestEnemy != null && !nearestEnemy.investigate)
                {
                    foreach (FOV fov in fovs)
                    {
                        fov.alert = FOV.alertState.normal;
                    }
                    nearestEnemy = null;
                }
            }

            switch (base.state)
            {
                case Enemy.enemyState.idle:
                    idle();
                    break;
                case Enemy.enemyState.playTurn:
                    playTurn();
                    break;
                default:
                    break;
            }
        }
    }