Пример #1
0
        public void SetDie(long id)
        {
            if (red.Find((unit) => unit.Id == id) != null)
            {
                foreach (var v in red)
                {
                    CharacterStateComponent unitStateComponent = v.GetComponent <CharacterStateComponent>();
                    if (!unitStateComponent.Get(SpecialStateType.Die))
                    {
                        return;
                    }
                }
                //TODO: 宣布蓝方胜利

                return;
            }

            if (blue.Find((unit) => unit.Id == id) != null)
            {
                foreach (var v in blue)
                {
                    CharacterStateComponent unitStateComponent = v.GetComponent <CharacterStateComponent>();
                    if (!unitStateComponent.Get(SpecialStateType.Die))
                    {
                        return;
                    }
                }
                //TODO: 宣布红方胜利

                return;
            }
        }
Пример #2
0
 public bool Failure(DungeonComponent dungeonCom)
 {
     foreach (var v in dungeonCom.playerTeam)
     {
         CharacterStateComponent unitStateComponent = v.GetComponent <CharacterStateComponent>();
         if (!unitStateComponent.Get(SpecialStateType.Die))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #3
0
        public void CollectCommandInput(ICommandInput input)
        {
            CharacterStateComponent property_CharacterState = GetParent <Unit>().GetComponent <CharacterStateComponent>();

            if (property_CharacterState.Get(SpecialStateType.CantDoAction) || property_CharacterState.Get(SpecialStateType.NotInControl))
            {
                return;
            }
            collectedNewInput = true;
            Command command = CommandGCHelper.GetCommand();

            command.commandInput          = input;
            currCommands[input.GetType()] = command;
        }
Пример #4
0
 public bool Victory(DungeonComponent dungeonCom)
 {
     foreach (var v in dungeonCom.currDungeonData[dungeonCom.currLevelIndex].datas)
     {
         if (!v.haveTriggerd)
         {
             return(false);
         }
     }
     foreach (var v in dungeonCom.enemyTeam)
     {
         CharacterStateComponent unitStateComponent = v.GetComponent <CharacterStateComponent>();
         if (!unitStateComponent.Get(SpecialStateType.Die))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #5
0
        //没法准确的在那一刻恢复,但是可以降低调用频率,尤其服务器,每个Update调用太耗了
        public void FixedUpdate()
        {
            if (TimeHelper.Now() - timer.timing >= timer.interval)
            {
                timer.timing += timer.interval;
                NumericComponent numericComponent = this.Entity.GetComponent <NumericComponent>();

                CharacterStateComponent unitStateComponent = this.Entity.GetComponent <CharacterStateComponent>();
                if (!unitStateComponent.Get(SpecialStateType.Die))
                {
                    return;
                }
                if (numericComponent.GetAsFloat(NumericType.HP_RemainPct) < 1.0f)
                {
                    if (unitStateComponent.Get(SpecialStateType.InBattle))
                    {
                        GetHP(numericComponent.GetAsInt(NumericType.HP_Restore));
                    }
                    else
                    {
                        GetHP(Mathf.RoundToInt(numericComponent.GetAsFloat(NumericType.HPMax_Final) * restorePct_NotInBattle));
                    }
                }
                if (numericComponent.GetAsFloat(NumericType.MP_RemainPct) < 1.0f)
                {
                    if (unitStateComponent.Get(SpecialStateType.InBattle))
                    {
                        GetMP(numericComponent.GetAsInt(NumericType.MP_Restore));
                    }
                    else
                    {
                        GetMP(Mathf.RoundToInt(numericComponent.GetAsFloat(NumericType.MPMax_Final) * restorePct_NotInBattle));
                    }
                }
            }
        }
        public override void Run(NumericType nt, long destUnitId, float updateValue)
        {
#if !SERVER
            if (GlobalConfigComponent.Instance.networkPlayMode)
            {
                return;
            }
#endif
            Unit             unit             = UnitComponent.Instance.Get(destUnitId);
            NumericComponent numericComponent = unit.GetComponent <NumericComponent>();

            CharacterStateComponent unitStateComponent = unit.GetComponent <CharacterStateComponent>();
            if (!unitStateComponent.Get(SpecialStateType.Die))
            {
                return;  //角色已经死亡,不再受到任何属性影响
            }
            switch (nt)
            {
            case NumericType.HP:

                int value    = numericComponent.GetAsInt(NumericType.HP) + Mathf.RoundToInt(updateValue);
                int maxValue = numericComponent.GetAsInt(NumericType.HPMax_Final);
                value = Mathf.Clamp(value, 0, maxValue);
                numericComponent.Set(NumericType.HP, value);
                Game.EventSystem.Run(EventIdType.HPChanged, destUnitId);
                if (value == 0)
                {
                    Game.EventSystem.Run(EventIdType.OnUnitDie, destUnitId);
                }
                break;

            case NumericType.MP:
                value    = numericComponent.GetAsInt(NumericType.MP) + Mathf.RoundToInt(updateValue);
                maxValue = numericComponent.GetAsInt(NumericType.MPMax_Final);
                value    = Mathf.Clamp(value, 0, maxValue);
                numericComponent.Set(NumericType.MP, value);
                Game.EventSystem.Run(EventIdType.MPChanged, destUnitId);
                break;

            //case NumericType.HPMax_Pct:
            //case NumericType.HP_LeechRate:
            //case NumericType.MPMax_Pct:
            //case NumericType.MP_LeechRate:
            //case NumericType.HitRate:
            //case NumericType.CritDamagePct:
            //case NumericType.CritRate:
            //case NumericType.DodgeRate:
            //case NumericType.FinalDamage_AddPct:
            //case NumericType.FinalDamage_ReducePct:
            //    //这些全都是百分比的值(float)
            //    float fvalue = numericComponent.GetAsFloat(nt) + updateValue;
            //    numericComponent.Set(nt, fvalue);
            //break;
            case NumericType.HP_LosePct:
            case NumericType.HP_RemainPct:
            case NumericType.MP_LosePct:
            case NumericType.MP_RemainPct:
            case NumericType.HP_LoseValue:
            case NumericType.MP_LoseValue:
                Log.Error("这些属性不应该被直接改变,它们是间接被改变的值");
                break;

            default:
                float fvalue = numericComponent.GetAsFloat(nt) + updateValue;
                numericComponent.Set(nt, fvalue);
                break;
            }
        }