Exemple #1
0
    private void Awake()
    {
        groundMask   = LayerMask.GetMask("Ground");
        stateManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;

        //Vector3 colliderWorldCoordinates = transform.TransformPoint(transform.root.GetComponent<BoxCollider2D>().size/2);

        BoxCollider2D rootBoxCollider = transform.root.GetComponent <BoxCollider2D>();

        //minX = colliderWorldCoordinates.x;
        //maxX = colliderWorldCoordinates.x;
        //minY = colliderWorldCoordinates.y;
        //maxY = colliderWorldCoordinates.y;
        minX = -transform.root.position.x + rootBoxCollider.bounds.min.x;
        maxX = -transform.root.position.x + rootBoxCollider.bounds.max.x;
        minY = -transform.root.position.y + rootBoxCollider.bounds.min.y;
        maxY = -transform.root.position.y + rootBoxCollider.bounds.max.y;
        // first is hit head on ground, second is grounded
        hitGroundTopAndGrounded = new bool[] { false, false };


        //print(rootBoxCollider.bounds.min.x);
        //print(transform.position.x);

        distanceBetweenRays = (maxX - minX) / (numberOfRaysPerSide - 1);
        if (numberOfRaysPerSide == 1)
        {
            distanceBetweenRays = 0;
        }

        //print(distanceBetweenRays);

        groundedState = new CharacterState(ConstantStrings.GROUNDED, hitGroundTopAndGrounded);
        stateManager.RegisterCharacterState(groundedState.name, groundedState);
    }
Exemple #2
0
    private void Awake()
    {
        stateManager     = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
        killedEnemyState = new CharacterState(ConstantStrings.KILLED_ENEMY, false);

        stateManager.RegisterCharacterState(killedEnemyState.name, killedEnemyState);
    }
Exemple #3
0
    // Use this for initialization
    void Awake()
    {
        ICharacterStateManager stateManager    = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
        CharacterState         speedScaleState = new CharacterState(ConstantStrings.SPEED_SCALE, 0f);

        stateManager.RegisterCharacterState(speedScaleState.name, speedScaleState);
    }
Exemple #4
0
 private void Awake()
 {
     stateManager    = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
     directionValues = new float[] { 0, 0 };
     directionState  = new CharacterState(ConstantStrings.DIRECTION, directionValues);
     stateManager.RegisterCharacterState(directionState.name, directionState);
 }
Exemple #5
0
    protected void Awake()
    {
        statesManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
        float[] emptyDirection = new float[] { 0, 0, 0 };
        directionState = new CharacterState(ConstantStrings.VELOCITY, emptyDirection);

        statesManager.RegisterCharacterState(directionState.name, directionState);
    }
    // Use this for initialization
    void Awake()
    {
        stateManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;

        transformationState = new CharacterState(ConstantStrings.TRANSFORMATION, transformation1);

        stateManager.RegisterCharacterState(transformationState.name, transformationState);
    }
Exemple #7
0
 private void EnablePlayerMovement()
 {
     //Gets reference to player's state manager if doesn't exist already. Need to get the reference each time a new
     //scene is loaded
     stateManager     = GameObject.FindGameObjectWithTag("Player").GetComponent <ICharacterStateManager>();
     disableMoveState = stateManager.GetExistingCharacterState(ConstantStrings.DISABLE_MOVE_STATE);
     disableMoveState.SetState(false);
 }
    private void Awake()
    {
        ICharacterStateManager statesManager               = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
        CharacterState         lightAttackCooldownState    = new CharacterState(ConstantStrings.LIGHT_ATTACK_COOLDOWN, new float[] { 0f, 0f });
        CharacterState         heavyAttackCooldownState    = new CharacterState(ConstantStrings.HEAVY_ATTACK_COOLDOWN, new float[] { 0f, 0f });
        CharacterState         utilityAbilityCooldownState = new CharacterState(ConstantStrings.UTILITY_COOLDOWN, new float[] { 0f, 0f });

        statesManager.RegisterCharacterState(lightAttackCooldownState.name, lightAttackCooldownState);
        statesManager.RegisterCharacterState(heavyAttackCooldownState.name, heavyAttackCooldownState);
        statesManager.RegisterCharacterState(utilityAbilityCooldownState.name, utilityAbilityCooldownState);
    }
    /*
     *  Need a new script that observes the moveset state and determines which ability casting module to spawn in the player
     */

    protected void Awake()
    {
        stateManager          = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
        moveSet               = GetComponent <MoveSet>();
        lightAttack           = moveSet.GetLightAttackHorizontalRight();
        heavyAttack           = moveSet.GetHeavyAttackHorizontalRight();
        utilityAbility        = moveSet.GetUtilityAbility();
        abilitySpawnDirection = new Vector2(0, -1);
        // initial default spawnlocation is down.
        abilitySpawnLocation = new Vector2(transform.root.position.x, transform.root.position.y);
    }
 void OnTriggerEnter2D(Collider2D col)
 {
     //If enemy is within stun range
     if (col.gameObject.tag == "Enemy")
     {
         //Get enemy's stateManager and set stun state to true momentarily to trigger subscription
         stateManager = col.gameObject.GetComponentInParent <ICharacterStateManager>();
         stunState    = stateManager.GetExistingCharacterState(ConstantStrings.Enemy.STUN_STATE);
         stunState.SetState(true);
         stunState.SetState(false);
     }
 }
    /*
     * Preinstantiate the objects for light and heavy melee attacks
     *
     */
    private new void Awake()
    {
        abilityCastingLock = false;
        stateManager       = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
        moveSet            = GetComponent <MoveSet>();
        GetAttackPrefabs();

        InstantiateAbilities();

        RegisterAttackLocks();
        SetTriggers();
        SetAttackDurations();
    }
 private void Awake()
 {
     stateManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
     if (stateManager.ExistsState(ConstantStrings.JUMPING))
     {
         jumpingState = stateManager.GetExistingCharacterState(ConstantStrings.JUMPING);
         jumpingState.SetState(false);
     }
     else
     {
         jumpingState = new CharacterState(ConstantStrings.JUMPING, false);
         stateManager.RegisterCharacterState(jumpingState.name, jumpingState);
     }
 }
Exemple #13
0
    protected void Awake()
    {
        stateManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;

        if (stateManager.ExistsState(inputName))
        {
            abilityCastingState = stateManager.GetExistingCharacterState(inputName);
            abilityCastingState.SetState(false);
        }
        else
        {
            abilityCastingState = new CharacterState(inputName, false);
            stateManager.RegisterCharacterState(abilityCastingState.name, abilityCastingState);
        }
    }
 // Use this for initialization
 void Start()
 {
     characterRigidBody       = GetComponentInParent <Rigidbody2D>();
     characterMovementHandler =
         transform.root.GetComponentInChildren(typeof(IMovementHandler)) as IMovementHandler;
     stateManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
     if (stateManager.ExistsState(ConstantStrings.MAGNET_STATE))
     {
         magnetState = stateManager.GetExistingCharacterState(ConstantStrings.MAGNET_STATE);
     }
     else
     {
         magnetState = new CharacterState(ConstantStrings.MAGNET_STATE, false);
         stateManager.RegisterCharacterState(magnetState.name, magnetState);
     }
 }
Exemple #15
0
 // Use this for initialization
 void Awake()
 {
     characterRigidBody       = GetComponentInParent <Rigidbody2D>();
     characterMovementHandler =
         transform.root.GetComponentInChildren(typeof(IMovementHandler)) as IMovementHandler;
     stateManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
     if (stateManager.ExistsState(ConstantStrings.RECOIL_STATE))
     {
         recoilState = stateManager.GetExistingCharacterState(ConstantStrings.RECOIL_STATE);
     }
     else
     {
         recoilState = new CharacterState(ConstantStrings.RECOIL_STATE, new bool[] { false, false });
         stateManager.RegisterCharacterState(recoilState.name, recoilState);
     }
 }
    // Use this for initialization
    void Start()
    {
        GameObject go = GameObject.FindGameObjectWithTag("Player");

        stateManager = go.GetComponent <ICharacterStateManager>();
        if (stateManager.ExistsState(ConstantStrings.MAGNET_STATE))
        {
            magnetState = stateManager.GetExistingCharacterState(ConstantStrings.MAGNET_STATE);
        }
        else
        {
            magnetState = new CharacterState(ConstantStrings.MAGNET_STATE, false);
            stateManager.RegisterCharacterState(magnetState.name, magnetState);
        }
        GameObject inventoryGameObject = GameObject.FindGameObjectWithTag("Inventory");

        inventory = inventoryGameObject.GetComponentInChildren <IInventory>();
    }
    private void Awake()
    {
        stateManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;

        currentJumpSpeedScale = jumpSpeedScale;
        currentFallSpeedScale = 0;

        if (stateManager.ExistsState(ConstantStrings.SPEED_SCALE))
        {
            speedScaleState = stateManager.GetExistingCharacterState(ConstantStrings.SPEED_SCALE);
            speedScaleState.SetState(new float[] { runSpeedScale, jumpSpeedScale, currentFallSpeedScale, runSpeedScale, jumpSpeedScale, fallSpeedScale });
        }
        else
        {
            speedScaleState = new CharacterState(ConstantStrings.SPEED_SCALE, new float[] { runSpeedScale, jumpSpeedScale, currentFallSpeedScale, runSpeedScale, jumpSpeedScale, fallSpeedScale });
            stateManager.RegisterCharacterState(speedScaleState.name, speedScaleState);
        }
    }
    private void Awake()
    {
        stateManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;

        lightAttackAnimationState = new CharacterState(
            ConstantStrings.PlayerAnimatorStates.LIGHT_ATTACK_ANIMATION,
            AnimationLocation.NotStarted
            );

        heavyAttackAnimationState = new CharacterState(
            ConstantStrings.PlayerAnimatorStates.HEAVY_ATTACK_ANIMATION,
            AnimationLocation.NotStarted
            );

        utilityAbilityAnimationState = new CharacterState(
            ConstantStrings.PlayerAnimatorStates.UTILITY_ABILITY_ANIMATION,
            AnimationLocation.NotStarted
            );

        idleHorizontalAnimationState = new CharacterState(
            ConstantStrings.PlayerAnimatorStates.IDLE_HORIZONTAL,
            AnimationLocation.NotStarted
            );

        idleVerticalAnimationState = new CharacterState(
            ConstantStrings.PlayerAnimatorStates.IDLE_VERTICAL,
            AnimationLocation.NotStarted
            );



        stateManager.RegisterCharacterState(lightAttackAnimationState.name,
                                            lightAttackAnimationState);
        stateManager.RegisterCharacterState(heavyAttackAnimationState.name,
                                            heavyAttackAnimationState);
        stateManager.RegisterCharacterState(utilityAbilityAnimationState.name,
                                            utilityAbilityAnimationState);
        stateManager.RegisterCharacterState(idleHorizontalAnimationState.name,
                                            idleHorizontalAnimationState);
        stateManager.RegisterCharacterState(idleHorizontalAnimationState.name,
                                            idleHorizontalAnimationState);
    }
    private void Awake()
    {
        stateManager          = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
        stats                 = GetComponent <UtilityAbilityStunGrenadeItemStats>();
        resourceAmount        = 0f;
        resourceDecreaseRate  = stats.GetResourceDechargeRate();
        resourceChargeRate    = stats.GetResourceChargeRate();
        resourceChargeHitRate = stats.GetResourceChargePerHit();

        if (!stateManager.ExistsState(ConstantStrings.UTILITY_RESOURCE_STATE))
        {
            stateManager        = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
            resourceChargeState = new CharacterState(ConstantStrings.UTILITY_RESOURCE_STATE, resourceAmount);
            stateManager.RegisterCharacterState(resourceChargeState.name, resourceChargeState);
        }
        else
        {
            resourceChargeState = stateManager.GetExistingCharacterState(ConstantStrings.UTILITY_RESOURCE_STATE);
        }
    }
Exemple #20
0
 private void Awake()
 {
     stateManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
     emptyUtilityResourceChargeState = new CharacterState(ConstantStrings.UTILITY_RESOURCE_STATE, 0f);
     stateManager.RegisterCharacterState(emptyUtilityResourceChargeState.name, emptyUtilityResourceChargeState);
 }
 void Awake()
 {
     stateManager     = GetComponentInParent <ICharacterStateManager>();
     disableMoveState = new CharacterState(ConstantStrings.DISABLE_MOVE_STATE, true);
     stateManager.RegisterCharacterState(disableMoveState.name, disableMoveState);
 }
 void Awake()
 {
     stateManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
     recoilState  = new CharacterState(ConstantStrings.RECOIL_STATE, new bool[] { false, false });
     stateManager.RegisterCharacterState(recoilState.name, recoilState);
 }
Exemple #23
0
 private void Awake()
 {
     stateManager    = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
     attackLockState = new CharacterState(attackLockName, false);
     stateManager.RegisterCharacterState(attackLockState.name, attackLockState);
 }
    //public bool testScoreStateToDisplayConnection = false;

    private void Awake()
    {
        statesManager = GetComponentInParent(typeof(ICharacterStateManager)) as ICharacterStateManager;
        scoreState    = new CharacterState(ConstantStrings.SCORE, (float)0);
        statesManager.RegisterCharacterState(scoreState.name, scoreState);
    }