public static IEnumerator Tackle(GameObject player, GameObject target)
        {
            if (CheckAnimatable(player) && CheckAnimatable(target))
            {
                GameManager.instance.Paused = true;
                while (!CheckIdle(player) || !CheckIdle(target))
                {
                    yield return(null);
                }
                TurnToFace(player, AEUtilities.PosToInt(target.transform.position));
                TurnToFace(target, AEUtilities.PosToInt(player.transform.position));
                yield return(null);

                while (!CheckIdle(player) || !CheckIdle(target))
                {
                    yield return(null);
                }
                player.GetComponent <Animator>().SetTrigger("lunge");
                target.GetComponent <Animator>().SetTrigger("stun");
                yield return(null);

                while (!CheckIdle(player) || target != null)
                {
                    yield return(null);
                }
                GameManager.instance.Paused = false;
            }
        }
Example #2
0
        public IEnumerator RunEvent(GameObject o)
        {
            GameManager.instance.Paused = true;
            Vector3Int newpos;

            if (AEUtilities.PosToInt(o.transform.position) != AEUtilities.PosToInt(transform.position + transform.forward))
            {
                if (locked)
                {
                    StartCoroutine(dialog.PlayEvent(dialogID));
                    yield break;
                }
                else
                {
                    newpos = AEUtilities.PosToInt(transform.position + transform.forward);
                }
            }
            else
            {
                newpos = AEUtilities.PosToInt(transform.position - transform.forward);
            }

            overlay.FadeIn(Color.black, 0.5f);
            yield return(new WaitForSeconds(0.5f));

            o.transform.position = newpos;
            yield return(new WaitForSeconds(0.1f));

            overlay.FadeOut(0.5f);
            yield return(new WaitForSeconds(0.5f));

            locked = false;
            GameManager.instance.Paused = false;
        }
        public static IEnumerator Attack(GameObject subject, GameObject target)
        {
            if (CheckAnimatable(subject) && CheckAnimatable(target))
            {
                GameManager.instance.Paused = true;
                while (!CheckIdle(subject) || !CheckIdle(target))
                {
                    yield return(null);
                }
                TurnToFace(subject, AEUtilities.PosToInt(target.transform.position));
                TurnToFace(target, AEUtilities.PosToInt(subject.transform.position));
                yield return(null);

                while (!CheckIdle(subject) || !CheckIdle(target))
                {
                    yield return(null);
                }
                subject.GetComponent <Animator>().SetTrigger("attack");
                target.GetComponent <Animator>().SetTrigger("defend");
                yield return(null);

                while (!CheckIdle(subject) || !CheckIdle(target))
                {
                    yield return(null);
                }
                Debug.Log("Animations should be finished.Idle boolean values for both entitie are: " +
                          subject.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("idle") + " " +
                          target.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("idle"));
                GameManager.instance.Paused = false;
            }
        }
        public IEnumerator TurnToFace(Vector3Int target)
        {
            if (!AEUtilities.CheckGridLinear(AEUtilities.PosToInt(transform.position), target))
            {
                yield break;
            }

            Vector3Int trueTarget = AEUtilities.GetAdjacentInt(AEUtilities.PosToInt(transform.position), target);

            int numRightTurns = 0;

            if (AEUtilities.PosToInt(transform.right * -1) == trueTarget)
            {
                adjusting = true;
                animator.SetTrigger("turn_left");
                yield return(null);

                while (!animator.GetCurrentAnimatorStateInfo(0).IsName("idle"))
                {
                    yield return(null);
                }
                adjusting = false;
            }
            else if (AEUtilities.PosToInt(transform.right) == trueTarget)
            {
                numRightTurns = 1;
            }
            else if (AEUtilities.PosToInt(transform.forward * -1) == trueTarget)
            {
                numRightTurns = 2;
            }
            else
            {
                yield break;
            }

            adjusting = true;
            for (int i = 0; i < numRightTurns; i++)
            {
                animator.SetTrigger("turn_right");
                yield return(null);

                while (!animator.GetCurrentAnimatorStateInfo(0).IsName("idle"))
                {
                    yield return(null);
                }
            }
            adjusting = false;
        }
 private static void TurnToFace(GameObject o, Vector3Int target)
 {
     if (AEUtilities.CheckGridLinear(AEUtilities.PosToInt(o.transform.position), target))
     {
         Vector3Int adjTarget = AEUtilities.GetAdjacentInt(AEUtilities.PosToInt(o.transform.position), target);
         if (adjTarget == AEUtilities.PosToInt(o.transform.position + o.transform.right))
         {
             o.GetComponent <Animator>().SetTrigger("turn_right");
         }
         else if (adjTarget == AEUtilities.PosToInt(o.transform.position + o.transform.right * -1))
         {
             o.GetComponent <Animator>().SetTrigger("turn_left");
         }
         else if (adjTarget == AEUtilities.PosToInt(o.transform.position + o.transform.forward * -1))
         {
             o.GetComponent <Animator>().SetTrigger("turn_180");
         }
     }
 }
Example #6
0
 private void Update()
 {
     if (!triggered)
     {
         GameObject o;
         if (AEUtilities.CheckTagAtLocation(AEUtilities.PosToInt(transform.position), "moving_entity", out o))
         {
             triggered = true;
             StartCoroutine(SpringTrap(o));
         }
     }
     else
     {
         if (!AEUtilities.CheckTagAtLocation(AEUtilities.PosToInt(transform.position), "moving_entity"))
         {
             triggered = false;
         }
     }
 }
Example #7
0
        public override string NextMove(out bool endTurn)
        {
            if (AEUtilities.PosToInt(transform.position) == coordinates[coordCounter])
            {
                coordCounter = (coordCounter + 1) % coordinates.Length;
            }
            Vector3Int nextPos = pathFinder.GetMoveTowards(AEUtilities.PosToInt(transform.position), coordinates[coordCounter], validMoveTags);

            if (AEUtilities.PosToInt(transform.position + transform.forward) == nextPos)
            {
                if (player.GetComponent <PlayerController>() != null && player.GetComponent <PlayerController>().Destination == nextPos)
                {
                    StartCoroutine(LabyrinthInteractions.Attack(gameObject, player));
                    endTurn = true;
                    return("");
                }
                else
                {
                    endTurn = true;
                    return("step");
                }
            }
            else
            {
                if (nextPos == AEUtilities.PosToInt(transform.position - transform.forward) || nextPos == AEUtilities.PosToInt(transform.position + transform.right))
                {
                    endTurn = false;
                    return("turn_right");
                }
                else if (nextPos == AEUtilities.PosToInt(transform.position - transform.right))
                {
                    endTurn = false;
                    return("turn_left");
                }
                else
                {
                    endTurn = true;
                    return("");
                }
            }
        }
 public void SnapToGrid()
 {
     transform.position = AEUtilities.PosToInt(transform.position);
     transform.rotation = AEUtilities.RotToCardinal(transform.rotation);
 }
        public override string NextMove(out bool endTurn)
        {
            destination = AEUtilities.PosToInt(transform.position);

            int vert  = (int)Input.GetAxisRaw("Vertical");
            int horiz = (int)Input.GetAxisRaw("Horizontal");

            if (Input.GetButtonDown("Submit"))
            {
                GameObject o;
                if (AEUtilities.CheckTagAtLocation(AEUtilities.PosToInt(transform.position + transform.forward), "check_event", out o))
                {
                    StartCoroutine(o.GetComponent <ICheckEvent>().RunEvent(gameObject));
                    endTurn = false;
                    return("");
                }
                else if (AEUtilities.CheckTagAtLocation(AEUtilities.PosToInt(transform.position + transform.forward), "hook"))
                {
                    endTurn     = true;
                    destination = AEUtilities.PosToInt(transform.position + (transform.forward * 2));
                    if (AEUtilities.CheckTagAtLocation(AEUtilities.PosToInt(transform.position + transform.forward * 2), "enemy", out o))
                    {
                        StartCoroutine(LabyrinthInteractions.Swing_Tackle(gameObject, o));
                        return("");
                    }
                    else
                    {
                        return("swing");
                    }
                }
                else
                {
                    endTurn     = true;
                    destination = AEUtilities.PosToInt(transform.position + transform.forward * 2);
                    if (AEUtilities.CheckTagAtLocation(AEUtilities.PosToInt(transform.position + transform.forward * 2), "enemy", out o))
                    {
                        StartCoroutine(LabyrinthInteractions.Tackle(gameObject, o));
                        return("");
                    }
                    else
                    {
                        return("lunge");
                    }
                }
            }
            else if (horiz == 1)
            {
                endTurn = false;
                return("turn_right");
            }
            else if (horiz == -1)
            {
                endTurn = false;
                return("turn_left");
            }
            else if (vert != 0)
            {
                Vector3Int move = AEUtilities.PosToInt(transform.position + transform.forward * vert);
                GameObject o;
                if (AEUtilities.CheckTagAtLocation(move, "pit"))
                {
                    if (AEUtilities.CheckTagAtLocation(AEUtilities.PosToInt(transform.position + transform.forward + (transform.up * -3)), "enemy", out o))
                    {
                        StartCoroutine(LabyrinthInteractions.JumpOn(gameObject, o));
                    }
                    else
                    {
                        StartCoroutine(LabyrinthInteractions.JumpDown(gameObject, move));
                    }
                    endTurn     = true;
                    destination = AEUtilities.PosToInt(transform.position + transform.forward + (transform.up * -3));
                    return("");
                }
                else if (AEUtilities.CheckTagAtLocation(move, "enemy", out o))
                {
                    StartCoroutine(LabyrinthInteractions.Attack(gameObject, o));
                    endTurn = false;
                    return("");
                }
                else if (AEUtilities.CheckTagAtLocation(move, "floor"))
                {
                    if (vert == 1)
                    {
                        endTurn     = true;
                        destination = AEUtilities.PosToInt(transform.position + transform.forward);
                        return("step_forward");
                    }
                    else if (vert == -1)
                    {
                        endTurn     = true;
                        destination = AEUtilities.PosToInt(transform.position - transform.forward);
                        return("step_back");
                    }
                }
            }

            endTurn = false;
            return("");
        }