Exemplo n.º 1
0
        public static AddUnitAction GetAddUnitAction(IUnitAction state)
        {
            AddUnitAction aus = new AddUnitAction();

            aus.TargetUnitTag = -1;
            if (state.GetType() == typeof(RotateAction))
            {
                aus.Rotate = (RotateAction)state;
            }
            else
            {
                aus.Rotate = null;
            }
            if (state.GetType() == typeof(MoveAction))
            {
                aus.Move = (MoveAction)state;
            }
            else
            {
                aus.Move = null;
            }
            if (state.GetType() == typeof(AttackAction))
            {
                aus.Attack = (AttackAction)state;
                if (aus.Attack.TargetUnit != null)
                {
                    aus.TargetUnitTag = aus.Attack.TargetUnit.Tag;
                }
                else
                {
                    aus.TargetUnitTag = -1;
                }
            }
            else
            {
                aus.Attack = null;
            }
            if (state.GetType() == typeof(DeathAction))
            {
                aus.Death = (DeathAction)state;
            }
            else
            {
                aus.Death = null;
            }
            return(aus);
        }