コード例 #1
0
    public void Initialize(BattleEntityComponent p_animatedTransform, BattleEntityComponent p_targetTransform, Anim_BattleAttack_Default_Conf p_animationConfiguration,
                           AttackDefinition p_attack)
    {
        this.AnimatedTransform = p_animatedTransform;
        this.TargetTransform   = p_targetTransform;
        this.Attack            = p_attack;

        this.AnimatedTransform.AnimatorDispatcher.registerListener(this, Anim_BattleAttack_Default.OnAnimatorEvent);

        this.Conf = p_animationConfiguration;

        this.LastFrameDistace = Vector3.Distance(this.AnimatedTransform.transform.position, this.TargetTransform.transform.position);

        this.State = (Anim_BattleAttack_Default_State)1;
        // this.AnimatedTransform.AnimatorDispatcher.Animator.StartPlayback
        this.AnimatedTransform.AnimatorDispatcher.Animator.Play(AnimatorStateConstants.Attack_Close_Prepare);

        this.InitalAnimatedTransform_Position = this.AnimatedTransform.transform.position;

        this.TargetPosition_MovingForward = this.AnimatedTransform.transform.position + ((this.LastFrameDistace - this.Conf.DistanceFromTarget) * Vector3.Normalize(this.TargetTransform.transform.position - this.AnimatedTransform.transform.position));

        this.Movement_ForwardDirection = Vector3.Normalize(this.TargetPosition_MovingForward - this.AnimatedTransform.transform.position);

        //Orient to transform to the target
        this.InitalAnimatedTransform_Rotation  = p_animatedTransform.transform.rotation;
        p_animatedTransform.transform.rotation = Quaternion.LookRotation(this.Movement_ForwardDirection, Vector3.up);
    }
コード例 #2
0
    public void update(BattleEntityTargetSelection p_battleTargetSelection)
    {
        if (p_battleTargetSelection.CurrentlySelectedEntity_HasChanged)
        {
            if (p_battleTargetSelection.CurrentlySelectedEntity_BattleIndex == BattleEntityTargetSelection.CurrentlySelectedEntity_BattleIndex_None)
            {
                if (this.IsEnabled)
                {
                    this.disable();
                }
                this.CurrentSelectedBattleEntityComponent = null;
            }
            else
            {
                if (!this.IsEnabled)
                {
                    this.enable();
                }

                this.CurrentSelectedBattleEntityComponent = BattleEntityComponent_Container.ComponentsByHandle[
                    Battle_Singletons._battleResolutionStep.BattleEntities[p_battleTargetSelection.CurrentlySelectedEntity_BattleIndex]
                                                            ];
                ;
            }
        }

        if (this.CurrentSelectedBattleEntityComponent != null)
        {
            this.BattleTargetSelectionUIGameObject.InstanciatedBattleTargetSelectionUIGameObject.transform.position = this.CurrentSelectedBattleEntityComponent.AboveHead_Transform.position;
        }
    }
コード例 #3
0
    private void Update()
    {
        float l_delta = Time.deltaTime;

        Battle_Singletons._battleActionSelection.update(l_delta);
        Battle_Singletons._battleTargetSelection.update(l_delta);

        SceneGlobalObjects.PlayerTurnInputflow.update(l_delta);

        Battle_Singletons._battleResolutionStep.update(l_delta);

        this.AtbUI.Update(l_delta);

        // Handling damage applied events
        if (Battle_Singletons._battleResolutionStep.Out_DamageApplied_Events.Count > 0)
        {
            for (int i = 0; i < Battle_Singletons._battleResolutionStep.Out_DamageApplied_Events.Count; i++)
            {
                BQEOut_FinalDamageApplied l_event        = Battle_Singletons._battleResolutionStep.Out_DamageApplied_Events[i];
                BattleEntityComponent     l_targetEntity = BattleEntityComponent_Container.ComponentsByHandle[l_event.Target];

                RectTransform l_instanciatedDamageTextObject = GameObject.Instantiate(this.DamageTextPrefab, SceneGlobalObjects.MainCanvas.transform);
                Text          l_instanciatedDamageText       = l_instanciatedDamageTextObject.GetComponentInChildren <Text>();
                l_instanciatedDamageText.text = l_event.FinalDamage.ToString();
                ((RectTransform)l_instanciatedDamageTextObject.transform).position = SceneGlobalObjects.MainCamera.WorldToScreenPoint(l_targetEntity.DamageDisplay_Transform.transform.position);

                BattleAnimation.onDamageReceived(l_targetEntity);
            }
        }

        // On battle entity death
        if (Battle_Singletons._battleResolutionStep.Out_Death_Events.Count > 0)
        {
            for (int i = 0; i < Battle_Singletons._battleResolutionStep.Out_Death_Events.Count; i++)
            {
                BattleEntity          l_deadEntity = Battle_Singletons._battleResolutionStep.Out_Death_Events[i];
                BattleEntityComponent l_destroyedEntityComponent = BattleEntityComponent_Container.ComponentsByHandle[l_deadEntity];

                SceneGlobalObjects.PlayerTurnInputflow.on_battleEntityDeath(l_destroyedEntityComponent);

                //handling selection
                Battle_Singletons._battleActionSelection.on_battleEntityDeath(l_destroyedEntityComponent.BattleEntityHandle);

                //handling target selection
                Battle_Singletons._battleTargetSelection.on_battleEntityDeath(i);

                //We update the BattleTargetSelectionUI is the _battleTargetSelection has changed by taking into account death
                SceneGlobalObjects.BattleTargetSelectionUI.update(Battle_Singletons._battleTargetSelection);

                l_destroyedEntityComponent.Dispose();
            }
            // Battle_Singletons._battleResolutionStep.Out_Death_Events.Clear();
        }

        BattleEntityComponent_Container.Update(l_delta);
    }
コード例 #4
0
 public void Initialize(BattleEntityComponent p_animatedTransform, BattleEntityComponent p_targetTransform)
 {
     this.AnimatedTransform = p_animatedTransform;
     this.TargetTransform   = p_targetTransform;
     p_animatedTransform.AnimatorDispatcher.registerListener(this, OnAnimatorEvent);
     p_animatedTransform.AnimatorDispatcher.Animator.Play(AnimatorStateConstants.Attack_Distance_MoveForward);
     this.State = Anim_BattleAttack_Distance_State.MovingForward;
     this.InitalAnimatedTransform_Rotation  = p_animatedTransform.transform.rotation;
     p_animatedTransform.transform.rotation = Quaternion.LookRotation((p_targetTransform.transform.position - p_animatedTransform.transform.position).normalized, Vector3.up);
 }
コード例 #5
0
 public static void onDamageReceived(BattleEntityComponent p_target)
 {
     switch (p_target.BattleEntityHandle.Type)
     {
     default:
     {
         p_target.AnimatorDispatcher.Animator.Play(AnimatorStateConstants.Damage_Received);
     }
     break;
     }
 }
コード例 #6
0
    public static Initialize_ReturnCode initialize_attackAnimation(BattleQueueEvent p_event)
    {
        switch (p_event.Type)
        {
        case BattleQueueEvent_Type.ATTACK:
        {
            BQE_Attack l_event = (BQE_Attack)p_event.Event;
            if (!l_event.Source.IsDead && !l_event.Target.IsDead)
            {
                switch (l_event.Attack.AttackType)
                {
                case Attack_Type.DEFAULT:
                {
                    switch (l_event.Source.Type)
                    {
                    case BattleEntity_Type.PLAYER_1:
                    {
                        BattleEntityComponent l_battleEntity = BattleEntityComponent_Container.ComponentsByHandle[l_event.Source];
                        l_event.Context_UserObject = new Anim_BattleAttack_Default();
                        ((Anim_BattleAttack_Default)l_event.Context_UserObject).Initialize(BattleEntityComponent_Container.ComponentsByHandle[l_event.Source],
                                                                                           BattleEntityComponent_Container.ComponentsByHandle[l_event.Target], ((PLAYER_1_conf)l_battleEntity.BattleEntityConfiguration).Animation_DefaultAttack, l_event.Attack);
                        l_battleEntity.BattleAnimations.push_attackAnimation(l_event, Anim_BattleAttack_Default.Update);
                        return(Initialize_ReturnCode.NEEDS_TO_BE_PROCESSED);
                    }

                    case BattleEntity_Type.PLAYER_2:
                    {
                        BattleEntityComponent l_battleEntity = BattleEntityComponent_Container.ComponentsByHandle[l_event.Source];
                        l_event.Context_UserObject = new Anim_BattleAttack_Default();
                        ((Anim_BattleAttack_Default)l_event.Context_UserObject).Initialize(BattleEntityComponent_Container.ComponentsByHandle[l_event.Source],
                                                                                           BattleEntityComponent_Container.ComponentsByHandle[l_event.Target], ((PLAYER_2_conf)l_battleEntity.BattleEntityConfiguration).Animation_DefaultAttack, l_event.Attack);
                        l_battleEntity.BattleAnimations.push_attackAnimation(l_event, Anim_BattleAttack_Default.Update);
                        return(Initialize_ReturnCode.NEEDS_TO_BE_PROCESSED);
                    }

                    case BattleEntity_Type.SOLIDER_MACHINEGUN_0:
                    {
                        BattleEntityComponent l_battleEntity = BattleEntityComponent_Container.ComponentsByHandle[l_event.Source];
                        l_event.Context_UserObject = new Anim_BattleAttack_Distance();
                        ((Anim_BattleAttack_Distance)l_event.Context_UserObject).Initialize(BattleEntityComponent_Container.ComponentsByHandle[l_event.Source],
                                                                                            BattleEntityComponent_Container.ComponentsByHandle[l_event.Target]);
                        l_battleEntity.BattleAnimations.push_attackAnimation(l_event, Anim_BattleAttack_Distance.Update);
                        return(Initialize_ReturnCode.NEEDS_TO_BE_PROCESSED);
                    }
                    }
                }
                break;
                }
            }
        }
        break;
        }
        return(Initialize_ReturnCode.NOTHING);
    }
コード例 #7
0
    public static AttackDefinition find_defaultAttackDefinition(BattleEntityComponent p_entityComponent)
    {
        switch (p_entityComponent.BattleEntityHandle.Type)
        {
        case BattleEntity_Type.PLAYER_1:
            return(((PLAYER_1_conf)p_entityComponent.BattleEntityConfiguration).DefaultAttack.AttackDefinition);

        case BattleEntity_Type.PLAYER_2:
            return(((PLAYER_2_conf)p_entityComponent.BattleEntityConfiguration).DefaultAttack.AttackDefinition);
        }

        return(new AttackDefinition());
    }
コード例 #8
0
 public void on_battleEntityDeath(BattleEntityComponent p_deadBattleEntityComponent)
 {
     switch (this.State)
     {
     case BattleSelectionFlowState.TARGETTING_ENTITY:
     {
         if (Battle_Singletons._battleActionSelection.CurrentlySelectedEntity == p_deadBattleEntityComponent.BattleEntityHandle)
         {
             this.set_state(BattleSelectionFlowState.IN_ACTIONSELECTION_MENU);
         }
     }
     break;
     }
 }
コード例 #9
0
        public static void decide_nextAction(BattleResolutionStep p_battle, BattleEntity p_actingEntity)
        {
            BattleEntityComponent l_actingEntityComponent = BattleEntityComponent_Container.ComponentsByHandle[p_actingEntity];

            switch (p_actingEntity.Type)
            {
            case BattleEntity_Type.SOLIDER_MACHINEGUN_0:
                decide_nextAction_default(p_battle, p_actingEntity, ((SOLIDER_MACHINEGUN_0_conf)l_actingEntityComponent.BattleEntityConfiguration).DefaultAttack.AttackDefinition);
                break;

            default:
                //TODO -> Introducing an attack of type NONE that does nothing but reset the ATB value of the Entity.
                //TODO -> This is just for testing purpose
                break;
            }
        }
コード例 #10
0
        public void Initialize(Creature leftCreature, Creature rightCreature)
        {
            componentSize = new Point(300, 500);

            leftCreatureComponent = new BattleEntityComponent(new Point(0, 0), componentSize)
            {
                backGroundTextureToLoad = "BorderBlack"
            };
            rightCreatureComponent = new BattleEntityComponent(displayRectangle.Width - componentSize.X, 0, componentSize.X, componentSize.Y)
            {
                backGroundTextureToLoad = "BorderBlack"
            };

            leftCreatureComponent.Initialize(leftCreature);
            rightCreatureComponent.Initialize(rightCreature);

            AddControl(leftCreatureComponent);
            AddControl(rightCreatureComponent);
        }
コード例 #11
0
    public void update(BattleEntityPlayerSelection p_battleActionSelection)
    {
        if (p_battleActionSelection.CurrentlySelectedEntity_HasChanged)
        {
            if (p_battleActionSelection.CurrentlySelectedEntity != null)
            {
                this.currentlySelectedbattleEntityComponent = BattleEntityComponent_Container.ComponentsByHandle[p_battleActionSelection.CurrentlySelectedEntity];
            }
            else
            {
                this.currentlySelectedbattleEntityComponent = null;
            }
        }

        //update transform
        if (this.currentlySelectedbattleEntityComponent != null)
        {
            this.Cursor.transform.position = this.currentlySelectedbattleEntityComponent.AboveHead_Transform.transform.position;
        }
    }