Exemple #1
0
        private void TargetClosestHydra()
        {
            var heads      = HydraHead.AllHeads;
            var curMinHead = heads[0];
            var curMinDist = Mathf.Infinity;

            foreach (var hydraHead in heads)
            {
                if (!hydraHead)
                {
                    return;
                }
                if (!hydraHead.IsAlive)
                {
                    continue;
                }
                var dist = Vector3.SqrMagnitude(transform.position - hydraHead.transform.position);
                if (!(dist < curMinDist))
                {
                    continue;
                }
                curMinHead = hydraHead;
                curMinDist = dist;
            }

            if (currentTarget == curMinHead)
            {
                return;
            }
            currentTarget            = curMinHead;
            destinationSetter.target = currentTarget.EnemiesTarget;
            onChangedTarget?.Invoke();
        }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     if (headsLeft > 0)
     {
         if (headToAttack == null)
         {
             bool allWaiting = true;
             foreach (HydraHead head in heads)
             {
                 if (head.state == HydraHead.State.ATTACKING ||
                     head.state == HydraHead.State.PAUSED ||
                     head.state == HydraHead.State.RETREATING)
                 {
                     allWaiting = false;
                 }
             }
             if (allWaiting)
             {
                 List <HydraHead> aliveHeads = new List <HydraHead>();
                 foreach (HydraHead head in heads)
                 {
                     if (head.status == HydraHead.Status.ALIVE && head.state == HydraHead.State.WAITING)
                     {
                         aliveHeads.Add(head);
                     }
                 }
                 if (aliveHeads.Count > 0)
                 {
                     int i = Random.Range(0, aliveHeads.Count);
                     headToAttack = aliveHeads[i];
                     timeToAttack = Random.Range(minTimeBetweenAttacks, maxTimeBetweenAttacks);
                     //HydraHead.attackTime = HydraHead.retreatTime = attackTimes[heads.Length - aliveHeads.Count];
                 }
                 else
                 {
                     //print("all heads are not ready to attack");
                 }
             }
         }
         else
         {
             timeToAttack -= Time.deltaTime;
             if (timeToAttack <= 0)
             {
                 timeToAttack = 0;
                 headToAttack.Attack();
                 headToAttack = null;
             }
         }
     }
     else
     {
         if (Time.time > setTime + victoryTime)
         {
             print("LEAVING");
             scriptManager.GetComponent <PlayerControl>().Die();
         }
     }
 }
Exemple #3
0
 public SnakeSpline(HydraHead h)
 {
     hh            = h;
     targetObject  = hh.targetObject;
     segmentLength = hh.segmentLength;
     numSegments   = hh.numSegments;
     tangentWeight = hh.tangentWeight;
     t             = new float[numSegments + 1];
     x             = new Vector3[numSegments + 1];
     r             = new Quaternion[numSegments];
 }
Exemple #4
0
 public void RestartGame()
 {
     ResetTimeScale();
     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     HydraHead.ResetHeads();
 }