예제 #1
0
    IEnumerator WaitForInput()
    {
        while (buffer.Count == 0)
        {
            yield return(null);
        }

        PlayerInputKey key = buffer[0];

        buffer.RemoveAt(0);

        if (key == PlayerInputKey.up)
        {
            DoAction(hitDigOrMove.GetAction(IntVector2.up), IntVector2.up);
        }
        else if (key == PlayerInputKey.right)
        {
            DoAction(hitDigOrMove.GetAction(IntVector2.right), IntVector2.right);
        }
        else if (key == PlayerInputKey.down)
        {
            DoAction(hitDigOrMove.GetAction(IntVector2.down), IntVector2.down);
        }
        else if (key == PlayerInputKey.left)
        {
            DoAction(hitDigOrMove.GetAction(IntVector2.left), IntVector2.left);
        }
        else
        {
            StartCoroutine(WaitForInput());
            yield break; //Break out to signify that valid input wasn't actually provided (don't call onPlayerAction;
        }

        intTransform.GetLevel().OnPlayerAction(this);
    }
예제 #2
0
    protected override void OnRecoverFinished()
    {
        IntVector2 direction = directions[index];
        Action     action    = hitDigOrMove.GetAction(direction);

        if (action.GetType() == typeof(ActionTryMove) && !hitDigOrMove.WillBump(direction))
        {
            index = (index + 1) % directions.Count;
        }
        DoAction(action, direction);
    }
예제 #3
0
    protected override void OnRecoverFinished()
    {
        int randIndex = Random.Range(0, randomDirections.Length);

        for (int i = 0; i < randomDirections.Length; i++)
        {
            IntVector2 direction = randomDirections[(randIndex + i) % randomDirections.Length];
            if (!hitDigOrMove.WillBump(direction) || i == randomDirections.Length - 1)
            {
                DoAction(hitDigOrMove.GetAction(direction), direction);
                return;
            }
        }
    }
예제 #4
0
    protected override void OnReadyForNextAction(GameObject target)
    {
        CheckAndUpdateIfInLineWithPlayer(target);

        IntVector2 currentPos = intTransform.GetPos();
        IntVector2 targetPos  = target.GetComponent <IntTransform>().GetPos();
        IntVector2 direction  = GetDirection(currentPos, targetPos);

        // If we don't have a shovel, this shouldn't be able to dig, instead change direction
        if (hitDigOrMove.WillBump(direction))
        {
            headingHorizontal = !headingHorizontal;
            direction         = GetDirection(currentPos, targetPos);
        }
        DoAction(hitDigOrMove.GetAction(direction), direction);

        if (target)
        {
            CheckAndUpdateIfInLineWithPlayer(target);
        }
    }
예제 #5
0
    protected override void OnRecoverFinished()
    {
        IntVector2 direction = IntVector2.zero;

        if (horizontal)
        {
            direction = to ? IntVector2.right : IntVector2.left;
        }
        else
        {
            direction = to ? IntVector2.up : IntVector2.down;
        }
        IntVector2 start = intTransform.GetPos();

        DoAction(hitDigOrMove.GetAction(direction), direction);
        IntVector2 end = intTransform.GetPos();

        if (start == end)
        {
            to = !to;
        }
    }
예제 #6
0
 protected override void OnRecoverFinished()
 {
     DoAction(hitDigOrMove.GetAction(direction), direction);
 }