示例#1
0
        private void ResetAttackFSM(SmartEntity troopEntity)
        {
            StaRTS.Utils.Diagnostics.Logger logger = Service.Logger;
            StateComponent stateComp = troopEntity.StateComp;

            if (stateComp == null)
            {
                logger.Error("ResetAttackFSM StateComp is null");
                return;
            }
            stateComp.Reset();
            TroopComponent troopComp = troopEntity.TroopComp;

            if (troopComp == null)
            {
                logger.Error("ResetAttackFSM TroopComp is null");
                return;
            }
            if (troopComp.TroopType == null)
            {
                logger.Error("ResetAttackFSM TroopVO is null");
                return;
            }
            ShooterComponent shooterComp = troopEntity.ShooterComp;

            if (shooterComp == null)
            {
                logger.Error("ResetAttackFSM ShooterComp is null");
                return;
            }
            TroopRole troopRole = shooterComp.ShooterVO.TroopRole;

            if (troopRole == TroopRole.None)
            {
                troopRole = shooterComp.OriginalShooterVO.TroopRole;
            }
            HealthType healthType = (troopRole != TroopRole.Healer) ? HealthType.Damaging : HealthType.Healing;

            shooterComp.Reset();
            shooterComp.AttackFSM = new AttackFSM(Service.BattleController, troopEntity, troopEntity.StateComp, shooterComp, troopEntity.TransformComp, healthType);
        }
        private void ResetAttackFSM(SmartEntity troopEntity)
        {
            StaRTSLogger   staRTSLogger = Service.Get <StaRTSLogger>();
            StateComponent stateComp    = troopEntity.StateComp;

            if (stateComp == null)
            {
                staRTSLogger.Error("ResetAttackFSM StateComp is null");
                return;
            }
            stateComp.Reset();
            TroopComponent troopComp = troopEntity.TroopComp;

            if (troopComp == null)
            {
                staRTSLogger.Error("ResetAttackFSM TroopComp is null");
                return;
            }
            ITroopDeployableVO troopType = troopComp.TroopType;

            if (troopType == null)
            {
                staRTSLogger.Error("ResetAttackFSM TroopVO is null");
                return;
            }
            HealthType       healthType  = troopType.IsHealer ? HealthType.Healing : HealthType.Damaging;
            ShooterComponent shooterComp = troopEntity.ShooterComp;

            if (shooterComp == null)
            {
                staRTSLogger.Error("ResetAttackFSM ShooterComp is null");
                return;
            }
            shooterComp.Reset();
            shooterComp.AttackFSM = new AttackFSM(Service.Get <BattleController>(), troopEntity, troopEntity.StateComp, shooterComp, troopEntity.TransformComp, healthType);
        }