コード例 #1
0
ファイル: Enemy.cs プロジェクト: LuisaPaetzold/PanicRoom
 public void ScareAway()
 {
     if (RetreatPosition != null)
     {
         transform.position = RetreatPosition.transform.position;
         retreated          = true;
         currentAttackTime  = 0f;
         vib.shiftVibrationsLegs(150);
         alreadyPlayedInLocation = false;
         currentPos = null;
         if (audioSource != null)
         {
             audioSource.PlayOneShot(DisappearSound);
         }
     }
 }
コード例 #2
0
ファイル: Enemy.cs プロジェクト: LuisaPaetzold/PanicRoom
    public void ChoosePositionAndMove()
    {
        if (movePositions != null)
        {
            List <GameObject> possiblePositions = new List <GameObject>();
            foreach (Transform child in movePositions.transform)
            {
                possiblePositions.Add(child.gameObject);
            }

            if (eyeData != null)
            {
                for (int i = possiblePositions.Count - 1; i >= 0; i--)
                {
                    GameObject posCandidate = possiblePositions[i];
                    if (posCandidate.transform == eyeData.GetLatestObjectHit())
                    {
                        possiblePositions.Remove(posCandidate);
                    }
                }
            }

            int children = possiblePositions.Count;
            int index    = Random.Range(0, children);

            GameObject newPos = possiblePositions[index];

            if (newPos != null)
            {
                transform.position = newPos.transform.position;
                currentPos         = newPos.GetComponent <MovePositions>();
                Debug.Log("Moved to: " + newPos.gameObject.name);
                retreated          = false;
                currentRetreatTime = 0f;
            }
        }
    }