Esempio n. 1
0
    public override bool DoInteracted(PowerupActor powerupActor, Direction direction, GameObject interactor)
    {
        CharacterActor otherCharacterActor = interactor.transform.root.GetComponent <CharacterActor>();

        if (otherCharacterActor)
        {
            // Empower buffables upon contact
            if (powerupActor.IsBrainBuffable(otherCharacterActor.brain))
            {
                if (otherCharacterActor.formStateMachine.currentState == otherCharacterActor.smallFormState)
                {
                    otherCharacterActor.SetForm(otherCharacterActor.bigFormState);
                    Destroy(powerupActor.gameObject);
                    return(true);
                }
                else if (otherCharacterActor.formStateMachine.currentState == otherCharacterActor.bigFormState)
                {
                    otherCharacterActor.SetForm(otherCharacterActor.powerFormState);
                    Destroy(powerupActor.gameObject);
                    return(true);
                }
            }
        }

        return(false);
    }
    public override bool DoInteracted(CharacterActor characterActor, Direction direction, GameObject interactor)
    {
        CharacterActor otherCharacterActor = interactor.GetComponent <CharacterActor>();

        if (otherCharacterActor)
        {
            Collider2D collision = otherCharacterActor.thisInteractionCollider2D;

            // Demote enemies to a smaller state or kill them if they are
            // below or the same y distance as Goomba
            if (characterActor.IsBrainEnemy(otherCharacterActor.brain))
            {
                if (Utilities.CheckOtherColliderDirection2D(Direction.Down, characterActor.thisInteractionCollider2D, collision))
                {
                    if (otherCharacterActor.formStateMachine.currentState != otherCharacterActor.smallFormState)
                    {
                        otherCharacterActor.SetForm(otherCharacterActor.smallFormState);
                        Debug.Log("small");
                        return(true);
                    }
                    else
                    {
                        otherCharacterActor.statusStateMachine.SetState(otherCharacterActor.deadStatusState);
                        Debug.Log("dead");
                        return(true);
                    }
                }
            }
        }

        return(false);
    }
Esempio n. 3
0
    public override void UpdateInput(CharacterActor characterActor)
    {
        if (!isUpdateInput)
        {
            return;
        }

        characterActor.inputAxis   = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        characterActor.isSprinting = Input.GetKey(KeyCode.LeftShift);
        characterActor.isJumping   = Input.GetKey(KeyCode.Space);

        if (Input.GetKeyDown(KeyCode.E))
        {
            characterActor.SetForm(characterActor.smallFormState);
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            characterActor.SetForm(characterActor.bigFormState);
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            characterActor.SetForm(characterActor.powerFormState);
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            characterActor.statusStateMachine.SetState(characterActor.normalStatusState);
        }

        if (Input.GetKeyDown(KeyCode.G))
        {
            characterActor.statusStateMachine.SetState(characterActor.deadStatusState);
        }
    }