Exemplo n.º 1
0
    public void HandleWallSliding(Vector2 directionalInput, Controller2D.CollisionInfo collisions, ref Vector3 velocity, ref float velocityXSmoothing)
    {
        wallDirX      = (collisions.left) ? -1 : 1;
        IsWallsliding = false;
        if ((collisions.left || collisions.right) && !collisions.below && velocity.y < 0)
        {
            IsWallsliding = true;

            if (velocity.y < -WallSlideSpeedMax)
            {
                velocity.y = -WallSlideSpeedMax;
            }

            if (timeToWallUnstick > 0)
            {
                velocityXSmoothing = 0;
                velocity.x         = 0;

                if (directionalInput.x != wallDirX && directionalInput.x != 0)
                {
                    timeToWallUnstick -= Time.deltaTime;
                }
                else
                {
                    timeToWallUnstick = WallStickTime;
                }
            }
            else
            {
                timeToWallUnstick = WallStickTime;
            }
        }
    }
Exemplo n.º 2
0
 public void PlayCard(AbilityCard card, Controller2D.CollisionInfo colInfo, PlayerAbilitySlot.SlotType slotType = PlayerAbilitySlot.SlotType.Cycling)
 {
     if (card.Activate(colInfo))
     {
         if (slotType == PlayerAbilitySlot.SlotType.Cycling)
         {
             TransferCard(card, DeckType.Library);
         }
     }
 }
Exemplo n.º 3
0
    private HeadState GetNextStateByEnvironment()
    {
        switch (state)
        {
        case HeadState.VerticalLoading:
            if (transform.localPosition.y < 5.4f)
            {
                return(HeadState.VerticalLoading);
            }
            else
            {
                return(HeadState.HorizontalLoading);
            }

        case HeadState.HorizontalLoading:
            if (transform.localPosition.x < 0.3f)
            {
                return(HeadState.HorizontalLoading);
            }
            else
            {
                return(HeadState.Waiting);
            }

        case HeadState.Waiting:
            if (Time.time >= stateEndTime)
            {
                return(HeadState.Launched);
            }
            else
            {
                return(HeadState.Waiting);
            }

        case HeadState.Launched:
            foreach (int layer in obstacles)
            {
                Controller2D.CollisionInfo collision = controller.Collisions;
                if (collision.above.Contains(layer) || collision.below.Contains(layer) || collision.front.Contains(layer) || collision.back.Contains(layer))
                {
                    return(HeadState.ObstacleHit);
                }
            }
            return(HeadState.Launched);

        case HeadState.ObstacleHit:
            return(HeadState.ObstacleHit);

        default:
            throw new Exception("Forbidden state for MissileHead : " + state);
        }
    }
Exemplo n.º 4
0
    public Vector2 GetDirectionalInput(Vector2 myPos, Controller2D.CollisionInfo collisionInfo)
    {
        if (collisionInfo.left)
        {
            return(new Vector2(1f, 0f));
        }
        if (collisionInfo.right)
        {
            return(new Vector2(-1f, 0f));
        }
        Vector2 targetPos = GameObject.FindGameObjectWithTag(tagToFollow).transform.position;

        return(new Vector2(Mathf.Sign(targetPos.x - myPos.x), 0));
    }
Exemplo n.º 5
0
    public bool Activate(Controller2D.CollisionInfo colInfo)
    {
        //List<SpecialAbility> abilitiesToUse = DetermineAbilityToActivate(colInfo.below);

        //int count = abilitiesToUse.Count;

        //for(int i = 0; i < count; i++) {
        //    abilitiesToUse[i].Activate();
        //}

        return(ActivateAllPossibleAbilities());

        //ability.Activate();
    }