Beispiel #1
0
        public void SwitchLocation(FighterObject fighterObject1, FighterObject fighterObject2)
        {
            if (fighterObject1.GetType() != fighterObject2.GetType() && !(fighterObject1 is NullFighterObject) &&
                !(fighterObject2 is NullFighterObject))
            {
                throw new InvalidFighterObjectException();
            }

            string fl1 = GetFighterObjectLocation(fighterObject1);
            string fl2 = GetFighterObjectLocation(fighterObject2);

            // Sort fighterObject if both have same state.
            if (fl1[0] == fl2[0] && fl1[1] > fl2[1])
            {
                string tempString = fl1;
                fl1 = fl2;
                fl2 = tempString;

                FighterObject tempObject = fighterObject1;
                fighterObject1 = fighterObject2;
                fighterObject2 = tempObject;
            }

            // Remove fighterObjects
            fighterLists[int.Parse(fl1[0].ToString())].Remove(fighterObject1);
            fighterLists[int.Parse(fl2[0].ToString())].Remove(fighterObject2);

            // Add fighterObjects in proper location
            fighterLists[int.Parse(fl1[0].ToString())].Insert(int.Parse(fl1[1].ToString()), fighterObject2);
            fighterLists[int.Parse(fl2[0].ToString())].Insert(int.Parse(fl2[1].ToString()), fighterObject1);

            // Change state
            FighterState tempState = fighterObject1.state;

            fighterObject1.ChangeState(fighterObject2.state);
            fighterObject2.ChangeState(tempState);
        }
Beispiel #2
0
 public bool MoveLocation(FighterObject fighterObject, FighterState state)
 {
     RemoveFighterObject(fighterObject);
     fighterObject.ChangeState(state);
     return(AddFighterObject(fighterObject));
 }