Exemple #1
0
 // Update is called once per frame
 void FixedUpdate()
 {
     // Life span
     linger--;
     // delay between multiple hits
     if (delayTime > 0)
     {
         delayTime--;
     }
     // if hit max times or life span ends
     if (linger <= 0 || timesHit >= maxHits)
     {
         GameObject.Destroy(this.gameObject);
     }
     // hits Battlers
     if (delayTime <= 0)
     {
         foreach (Battler i in objectsToHit)
         {
             if (hitBox.HitTest(i.hurtBox) && i.alliance != alliance)
             {
                 //Debug.Log("Pain Box hit " + i.name + "!");
                 //i.GetHit(effects.push * facing, effects.lift, effects.damage);
                 //i.GetHit(0, 0, 5);
                 timesHit++;
                 //resets delay
                 delayTime += hitDelay;
             }
         }
     }
 }
Exemple #2
0
    //===========================================================FIXEDUPDATE=====================================================
    void FixedUpdate()
    {
        // Uncontrolled: ----------------------------------------UNCONTROLLED----------------------------------------------------

        // VARIABLESUPDATE
        VariablesUpdate();
        // Neutral Animation

        /*if (currentState == Action.NEUTRAL)
         * {
         *  NeutralAnimation();
         * }*/
        if (currentState == Action.DOWN)
        {
            thisAnimation.Play("dead");
        }


        // Controlled: ------------------------------------------CONTROLLED------------------------------------------------------
        if (currentState == Action.NEUTRAL && !airborne && actionPoints >= 1)
        {
            NeutralAnimation();
            // Neutral actions
            // Moving
            if (movementX != 0)
            {
                facing = movementX;
                if (movementX >= 1)
                {
                    position.x += moveSpeed * actionSpeed;
                }
                else if (movementX <= -1)
                {
                    position.x -= moveSpeed * actionSpeed;
                }
            }
            // Lane Change
            if (movementY != 0)
            {
                if (movementY >= 1 && position.lane < BattleManager.Manager.field.lanes - 1)
                {
                    laneChange += actionSpeed;
                }
                else if (movementY <= -1 && position.lane > 0)
                {
                    laneChange -= actionSpeed;
                }
            }
            else
            {
                laneChange = 0;
            }
            if (laneChange >= 30)
            {
                position.lane += 1;
                laneChange     = 0;
            }
            if (laneChange <= -30)
            {
                position.lane -= 1;
                laneChange     = 0;
            }
            // Block
            if (defend)
            {
                currentState = Action.ACTING;
                action       = blockDelay;
                blockFrames  = blockDelay;
            }
            // Jumping

            /*if (jump && airborne == false)
             * {
             *  velocity.y = jumpStrength;
             *  jump = false;
             * }*/
        }
        // Using a Basic Attack ---------------------------------ATTACKING-------------------------------------------------------
        if (attackBasic && canAction)
        {
            Debug.Log("Basic attack Input!");
            ExecuteAction(BattlerAction.BasicAttack);

            actionPoints -= 1;
        }
        // Using a Mat Skill ---------------------------------------------
        if (matSkill && canAction)
        {
            // Side attack
            if (movementX != 0)
            {
                facing = movementX;
                Debug.Log("Side attack Input!");
                ExecuteAction(skills.materialSide);
            }
            else if (movementY != 0)
            {
                // UP Attack
                if (movementY > 0)
                {
                    Debug.Log("Up attack Input!");
                    ExecuteAction(skills.materialUp);
                }//Down Attack
                else if (movementY < 0)
                {
                    Debug.Log("Down attack Input!");
                    ExecuteAction(skills.materialDown);
                }
            }// Neutral Attack
            else
            {
                Debug.Log("Neutral attack Input!");
                ExecuteAction(skills.materialNeutral);
            }

            actionPoints -= 1;
        }

        // UnControlled2 ----------------------------------------UNCONTROLLED2---------------------------------------------------
        // While Attacking(Acting) ==============================WHILEACTING=====================================================
        // Action Execution
        if (currentState == Action.ACTING)
        {
            if (execution >= currentFrame + 1)
            {
                currentFrame++;
                currentFrameExecuted = false;
            }
            //make hits on strike frames If action is an atttack
            foreach (BAStrike sFrame in currentAction.strikeFrames)
            {
                if (currentFrame == sFrame.frame && !currentFrameExecuted)
                {
                    SetAttHitBox(1.3f);
                    // Hit other battlers
                    for (int i = 0; i < BattleManager.Manager.AllBattlers.Count; i++)
                    {     // Other battlers
                        if (BattleManager.Manager.AllBattlers[i] != this && BattleManager.Manager.AllBattlers[i].alliance != alliance && BattleManager.Manager.AllBattlers[i].alive)
                        { // Not itself, not same team and is alive
                            if (attachedHitBox.HitTest(BattleManager.Manager.AllBattlers[i].hurtBox))
                            {
                                // If a target is hit!
                                DamageCVars damageV = new DamageCVars();
                                damageV.amount      = Mathf.Round(sFrame.power * attackDamage);
                                damageV.attackerAcc = accuracy;

                                BattleManager.Manager.AllBattlers[i].GetHit(sFrame.push * facing, sFrame.lift, damageV);
                            }
                        }
                    }
                }
            }
            foreach (BAMovement i in currentAction.movementFrames)
            {
                if (currentFrame == i.frame && !currentFrameExecuted)
                {
                    velocity = new Vector2(i.forward * facing, i.jump);
                }
            }

            // canAttack in combo frames
            if (execution > currentAction.executionFrames && execution <= currentAction.comboLimit)
            {
                //canAttack = true;
            }
            else
            {
                canAttack = false;
            }
            currentFrameExecuted = true;
            execution           += actionSpeed;
        }

        // PHYSICSUPDATE
        PhysicsUpdate();
    }