Esempio n. 1
0
        public override void OnStateChanged(VoxelDataState prevState, VoxelDataState newState)
        {
            base.OnStateChanged(prevState, newState);

            if (prevState == VoxelDataState.Mutating)
            {
                UpdateProgressUI(false);
                m_isInProgress = false;
            }
        }
Esempio n. 2
0
        protected void OnInstantCmd(VoxelDataState state, int beginCmdCode, Cmd cmd, int delay, int duration)
        {
            State = state;

            if (beginCmdCode != CmdCode.Nop)
            {
                Cmd beginCmd = cmd.Clone();
                beginCmd.Code = beginCmdCode;

                beginCmd.Duration = delay;
                m_commandsQueue.Enqueue(beginCmd);
            }

            cmd.Duration = duration;
            m_commandsQueue.Enqueue(cmd);
        }
Esempio n. 3
0
        protected virtual void OnStateChanged(Cmd cmd)
        {
            ChangeParamsCmd changeParamsCmd = (ChangeParamsCmd)cmd;

            VoxelDataState prevState = m_dataController.GetVoxelDataState();

            CmdResultCode noFail = m_dataController.SetVoxelDataState((VoxelDataState)changeParamsCmd.IntParams[1]);

            if (noFail != CmdResultCode.Success)
            {
                throw new InvalidOperationException();
            }

            if (m_controlledVoxel != null)
            {
                m_controlledVoxel.OnStateChanged(prevState, m_dataController.GetVoxelDataState());
            }
        }
Esempio n. 4
0
        protected override void OnEvaluating(ExpressionInfo expression, IMatchPlayerView player, IMatchUnitAssetView unit, ITaskEngine taskEngine, Action <object> callback)
        {
            VoxelDataState state = unit.DataController.GetVoxelDataState();

            callback(state);
        }
Esempio n. 5
0
 public virtual void OnStateChanged(VoxelDataState prevState, VoxelDataState newState)
 {
 }
Esempio n. 6
0
 public override void OnStateChanged(VoxelDataState prevState, VoxelDataState newState)
 {
     base.OnStateChanged(prevState, newState);
     UpdateUI(false);
 }
Esempio n. 7
0
        public void Tick(long tick, out Cmd cmd)
        {
            if (m_createdVoxels.Count != 0)
            {
                m_createdVoxels.Clear();
            }

            if (m_eatenOrDestroyedVoxels.Count != 0)
            {
                m_eatenOrDestroyedVoxels.Clear();
            }

            if (!m_dataController.IsAlive)
            {
                if (State != VoxelDataState.Idle)
                {
                    RaiseCmdFailed(null, CmdResultCode.Fail_NoUnit);
                }
                else
                {
                    GoToIdleState();
                }
                cmd = null;
                return;
            }

            if (m_ticksBeforeNextCommand == 0)
            {
                cmd = OnTick(tick);

                if (State != m_prevState)
                {
                    if (cmd != null)
                    {
                        cmd = new CompositeCmd
                        {
                            UnitIndex = cmd.UnitIndex,
                            Duration  = cmd.Duration,
                            Commands  = new[]
                            {
                                cmd,
                                new ChangeParamsCmd(CmdCode.StateChanged)
                                {
                                    UnitIndex = cmd.UnitIndex,
                                    Duration  = cmd.Duration,
                                    IntParams = new[]
                                    {
                                        (int)m_prevState,
                                        (int)State
                                    }
                                }
                            }
                        };
                    }
                    else
                    {
                        cmd = new ChangeParamsCmd(CmdCode.StateChanged)
                        {
                            UnitIndex = Id,
                            IntParams = new[]
                            {
                                (int)m_prevState,
                                (int)State
                            }
                        };
                    }

                    CmdResultCode noFail = m_dataController.SetVoxelDataState(State);
                    if (noFail != CmdResultCode.Success)
                    {
                        throw new InvalidOperationException("");
                    }
                    m_prevState = State;
                }

                return;
            }
            else
            {
                m_ticksBeforeNextCommand--;
            }

            cmd = null;
            return;
        }