// Update is called once per frame
    void Update()
    {
        float[] playerVelocity  = (float[])stateObserver.GetCharacterStateValue(ConstantStrings.VELOCITY);
        float   playerXVelocity = playerVelocity[0];
        float   playerYVelocity = playerVelocity[1];

        if (playerXVelocity != 0)
        {
            playerAnimator.SetBool(runningHash, true);
        }
        else
        {
            playerAnimator.SetBool(runningHash, false);
        }
        if (playerYVelocity < 0)
        {
            playerAnimator.SetBool(fallingHash, true);
        }
        else
        {
            playerAnimator.SetBool(fallingHash, false);
        }
        if (playerYVelocity > 0)
        {
            playerAnimator.SetBool(jumpingHash, true);
        }
        else
        {
            playerAnimator.SetBool(jumpingHash, false);
        }


        playerAnimator.SetBool(heavyAttackHash,
                               (bool)stateObserver.GetCharacterStateValue(ConstantStrings.HEAVY_ATTACK_CAST));
    }
Beispiel #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        float[] velocity           = (float[])stateObserver.GetCharacterStateValue(ConstantStrings.VELOCITY);
        float[] speedScaleValues   = (float[])stateObserver.GetCharacterStateValue(ConstantStrings.SPEED_SCALE);
        float   runSpeedScaleValue = speedScaleValues[0];

        characterRigidbody.position +=
            new Vector2(velocity[0] * runSpeedScaleValue, 0) * Time.deltaTime;
    }
    // Use this for initialization
    void Start()
    {
        currentHealth = (int)(float)stateObserver.GetCharacterStateValue(ConstantStrings.CURRENT_HEALTH);
        maxHealth     = (int)(float)stateObserver.GetCharacterStateValue(ConstantStrings.MAX_HEALTH);
        SubscribeToHealthChanges();

        healthContainers = new List <GameObject>();
        DrawInitialContainers();
    }
    // Update is called once per frame
    void Update()
    {
        float[] bossVelocity  = (float[])stateObserver.GetCharacterStateValue(ConstantStrings.VELOCITY);
        float   bossXVelocity = bossVelocity[0];
        float   bossYVelocity = bossVelocity[1];

        //If boss is walking
        if (bossXVelocity != 0)
        {
            bossAnimator.SetBool(walkingHash, true);
        }
        else
        {
            bossAnimator.SetBool(walkingHash, false);
        }
        //If boss is jumping
        if (bossYVelocity > 0)
        {
            bossAnimator.SetBool(jumpingHash, true);
        }
        else
        {
            bossAnimator.SetBool(jumpingHash, false);
        }
        //If boss is falling
        if (bossYVelocity < 0)
        {
            bossAnimator.SetBool(fallingHash, true);
        }
        else
        {
            bossAnimator.SetBool(fallingHash, false);
        }
    }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        transformationStateSubscription = stateObserver.GetCharacterStateSubscription(ConstantStrings.TRANSFORMATION);
        currentTransformationStateValue = stateObserver.GetCharacterStateValue(ConstantStrings.TRANSFORMATION);

        currentAbilityCaster = Instantiate(((GameObject)currentTransformationStateValue).GetComponent <CharacterTransformationBundle>().GetCaster(), transform);
        transformationStateSubscription.OnStateChanged += SwitchCasterObject;
    }
Beispiel #6
0
 // Update is called once per frame
 void Update()
 {
     float[] characterDirection = (float[])stateObserver.GetCharacterStateValue(ConstantStrings.DIRECTION);
     if (characterDirection[0] < 0)
     {
         transform.localScale = new Vector3(-1, 1, 1);
     }
     if (characterDirection[0] > 0)
     {
         transform.localScale = new Vector3(1, 1, 1);
     }
 }
Beispiel #7
0
    // Update is called once per frame
    void FixedUpdate()
    {
        /*
         * Wait for speed scale to be instantiated then get the values
         */
        if (!gottenSpeedScale)
        {
            playerHorizontalMoveSpeed = ((float[])stateObserver.GetCharacterStateValue(ConstantStrings.SPEED_SCALE))[3];
            gottenSpeedScale          = true;
        }
        newCameraPositionX = transform.position.x;

        /*
         * Check if directors available and use if relevant
         */
        RaycastHit2D[] directors = CheckForDirector();
        if (directors.Length > 0)
        {
            int directed = 0;
            foreach (RaycastHit2D director in directors)
            {
                directed += ChooseDirectorStrategy(director.collider.GetComponent <BoxCollider2D>());
            }

            /*
             * bool useDefaultStrat is equal to whether or not other strats were used
             */
            useDefaultStrat = directed == 0;
        }
        else
        {
            useDefaultStrat = true;
        }

        /*
         * Use default strat if no other strats were used
         */
        if (useDefaultStrat)
        {
            UseDefaultStrategy();
        }

        transform.position = new Vector3(newCameraPositionX, transform.position.y, transform.position.z);
    }
 public void TriggerAttack()
 {
     float[] playerdirection = (float[])stateObserver.GetCharacterStateValue(ConstantStrings.DIRECTION);
     if (playerdirection[1] > 0)
     {
         GameObject instance = Instantiate(stunGrenade, transform.position + Vector3.up, Quaternion.identity);
         instance.GetComponent <UtilityStunGrenadeMovement>().SetDirection(Vector2.up);
     }
     else if (playerdirection[1] < 0)
     {
         GameObject instance = Instantiate(stunGrenade, transform.position + Vector3.down, Quaternion.identity);
         instance.GetComponent <UtilityStunGrenadeMovement>().SetDirection(Vector2.down);
     }
     else if (playerdirection[0] < 0)
     {
         GameObject instance = Instantiate(stunGrenade, transform.position + Vector3.left, Quaternion.identity);
         instance.GetComponent <UtilityStunGrenadeMovement>().SetDirection(Vector2.left);
     }
     else
     {
         GameObject instance = Instantiate(stunGrenade, transform.position + Vector3.right, Quaternion.identity);
         instance.GetComponent <UtilityStunGrenadeMovement>().SetDirection(Vector2.right);
     }
 }
    // Update is called once per frame
    void FixedUpdate()
    {
        newCameraPositionY = transform.position.y;

        if (!gottenSpeedScales)
        {
            playerJumpMoveSpeed = ((float[])stateObserver.GetCharacterStateValue(ConstantStrings.SPEED_SCALE))[4];
            playerFallMoveSpeed = ((float[])stateObserver.GetCharacterStateValue(ConstantStrings.SPEED_SCALE))[5];
            gottenSpeedScales   = true;
        }
        playerCurrentJumpMoveSpeed = ((float[])stateObserver.GetCharacterStateValue(ConstantStrings.SPEED_SCALE))[1];
        playerCurrentFallMoveSpeed = ((float[])stateObserver.GetCharacterStateValue(ConstantStrings.SPEED_SCALE))[2];
        RaycastHit2D[] directors = CheckForDirector();
        if (directors.Length > 0)
        {
            int directed = 0;
            foreach (RaycastHit2D director in directors)
            {
                directed += ChooseDirectorStrategy(director.collider.GetComponent <BoxCollider2D>());
            }

            /*
             * bool useDefaultStrat is equal to whether or not other strats were used
             */
            useDefaultStrat = directed == 0;
        }
        else
        {
            useDefaultStrat = true;
        }

        if (useDefaultStrat)
        {
            UseDefaultStrategy();
        }

        transform.position = new Vector3(transform.position.x, newCameraPositionY, transform.position.z);
    }
 // Update is called once per frame
 void Update()
 {
     resourceBarFill.fillAmount = (float)stateObserver.GetCharacterStateValue(ConstantStrings.UTILITY_RESOURCE_STATE);
 }
 private void Start()
 {
     onDeadSubscription = stateObserver.GetCharacterStateSubscription(ConstantStrings.DEATH_STATE);
     onDeadSubscription.OnStateChanged += OnDeathSendScore;
     currentDeathState = (bool)stateObserver.GetCharacterStateValue(ConstantStrings.DEATH_STATE);
 }