コード例 #1
0
        private void ResolveHP(PawnStatistics _src, PawnStatistics _target, ResolveResult _result)
        {
            float weaponBonus = 0;

            if (_src.m_EquippedWeapon != null)
            {
                Weapon wpn = _src.m_EquippedWeapon;
                weaponBonus = wpn.m_Atk + UnityEngine.Random.Range(-wpn.m_AtkR, wpn.m_AtkR);
            }

            float dmg = (_src.m_Atk * m_DamageFactor) + weaponBonus - _target.m_Def;

            if (dmg < 0)
            {
                dmg = 0;
            }
            int realDamage = (int)dmg;

            _result.m_Damage = realDamage;

            _target.m_HP -= realDamage;

            if (_target.m_HP <= 0)
            {
                _target.m_HP = 0;
                PawnBehavior behavior = _target.GetComponent <PawnBehavior>();
                behavior.SetDeadState();
            }
        }
コード例 #2
0
        public void Resolve(ResolveResult _result)
        {
            PawnStatistics pawnStats   = m_Pawn.GetComponent <PawnStatistics>();
            PawnStatistics targetStats = m_Target.GetComponent <PawnStatistics>();

            float weaponBonus = 0;

            if (pawnStats.m_EquippedWeapon != null)
            {
                Weapon wpn = pawnStats.m_EquippedWeapon;
                weaponBonus = wpn.m_Atk + Random.Range(-wpn.m_AtkR, wpn.m_AtkR);
            }

            float dmg = pawnStats.m_Atk + weaponBonus - targetStats.m_Def;

            if (dmg < 0)
            {
                dmg = 0;
            }
            int realDamage = (int)dmg;

            targetStats.m_HP -= realDamage;
            if (targetStats.m_HP <= 0)
            {
                targetStats.m_HP = 0;
                PawnBehavior behavior = m_Target.GetComponent <PawnBehavior>();
                behavior.SetDeadState();
            }

            _result.m_Damage = realDamage;
        }
コード例 #3
0
        private void InitializePawnStatistics(GameObject _pawn)
        {
            GameTurnManager turnMng = GameTurnManager.GetInstance();

            PawnBehavior bhv            = _pawn.GetComponent <PawnBehavior>();
            Character    savedCharacter = GameStateManager.GetInstance().GetCharacter(bhv.m_CharacterId);

            PawnStatistics stats = _pawn.GetComponent <PawnStatistics>();

            savedCharacter.LoadTo(stats);
        }
コード例 #4
0
        public override void OnEnter()
        {
            foreach (GameObject obj in GameTurnManager.GetInstance().m_PlayerPawns)
            {
                PawnBehavior   bhv   = obj.GetComponent <PawnBehavior>();
                PawnStatistics stats = obj.GetComponent <PawnStatistics>();
                GameStateManager.GetInstance().GetCharacter(bhv.m_CharacterId).SaveFrom(stats);
            }

            GameSceneManager.GetInstance().Pop(true);

            LevelMaster.GetInstance().ComeBackFromBattle();
        }
コード例 #5
0
        void OnEnable()
        {
            GameTurnManager turnMng    = GameTurnManager.GetInstance();
            int             enemyCount = turnMng.m_EnemiesPawns.Count;
            int             buttonUsed = 0;

            for (int i = 0; i < enemyCount; ++i)
            {
                GameObject   objPawn = turnMng.m_EnemiesPawns[i];
                PawnBehavior bhv     = objPawn.GetComponent <PawnBehavior>();
                if (bhv.m_State == PawnState.Dead)
                {
                    continue;
                }

                CustomButton btn = m_BtnEnemies[buttonUsed];
                btn.gameObject.SetActive(true);
                Text txt = btn.transform.GetComponentInChildren <Text>();
                txt.text = objPawn.GetComponent <PawnStatistics>().m_PawnName;

                btn.onClick.RemoveAllListeners();
                btn.onClick.AddListener(() => { Click(objPawn); });

                btn.onCancel.RemoveAllListeners();
                btn.onCancel.AddListener(() => { Cancel(); });

                btn.onSelect.RemoveAllListeners();
                btn.onSelect.AddListener(() => { Select(objPawn); });

                btn.onDeselect.RemoveAllListeners();
                btn.onDeselect.AddListener(() => { Deselect(); });

                btn.Send(WidgetEvent.Unselect);

                ++buttonUsed;
            }

            for (int i = buttonUsed; i < m_BtnEnemies.Length; ++i)
            {
                CustomButton btn = m_BtnEnemies[i];
                btn.gameObject.SetActive(false);
            }

            m_BtnEnemies[0].Send(WidgetEvent.Select);
            m_Cursor.SetActive(true);
        }
コード例 #6
0
        public void Prepare()
        {
            m_InitialOrientation = m_Pawn.transform.localRotation;
            m_InitialPosition    = m_Pawn.transform.position;
            m_TargetPosition     = m_Target.transform.position;
            m_TargetPosition.y   = m_InitialPosition.y;

            Vector3 direction = m_TargetPosition - m_InitialPosition;

            PawnBehavior pawnBhv          = m_Pawn.GetComponent <PawnBehavior>();
            PawnBehavior targetBhv        = m_Target.GetComponent <PawnBehavior>();
            float        distanceToTravel = direction.magnitude - m_AttackDistance - pawnBhv.m_AttackAnchorRadius - targetBhv.m_AttackAnchorRadius;

            m_AttackPosition = m_InitialPosition + direction.normalized * distanceToTravel;

            m_TravelTime = distanceToTravel / m_Speed;

            m_State = CloseUpAttackState.StartMoveToEnemy;

            m_TimeStartTravel = Time.fixedTime;
        }