Exemplo n.º 1
0
        void ObjectDestructed(BaseObject ob)
        {
            ob.Destructed -= ObjectDestructed;

            var movable = ob as MovableObject;

            if (movable != null)
            {
                movable.PropertyChanged -= MovablePropertyChanged;
            }

            var env = ob as EnvironmentObject;

            if (env != null)
            {
                m_environments.Remove(env);
            }

            m_rootObjects.Remove(ob);

            if (m_objects.Remove(ob) == false)
            {
                throw new Exception();
            }

#if TRACK_DESTRUCTED_OBJECTS
            m_destructedObjects.Add(ob);
#endif
        }
Exemplo n.º 2
0
    public void MoveUnit(Type type, Point curPoint, Point newPoint)
    {
        switch (type)
        {
        case Type.Envrionment:

            if (!EnvironmentCollection.ContainsKey(curPoint) || EnvironmentCollection.ContainsKey(newPoint))
            {
                Debug.LogError("[EnvironmentManager] Failed to set unit to new position");
                return;
            }

            EnviromentalUnit temp = EnvironmentCollection[curPoint];
            EnvironmentCollection.Remove(curPoint);
            EnvironmentCollection.Add(newPoint, temp);
            break;

        case Type.Enemy:

            if (!EnemyCollection.ContainsKey(curPoint) || EnemyCollection.ContainsKey(newPoint))
            {
                Debug.LogError("[EnvironmentManager] Failed to set unit to new position");
                return;
            }

            EnemyUnit enemyTemp = EnemyCollection[curPoint];
            EnemyCollection.Remove(curPoint);
            EnemyCollection.Add(newPoint, enemyTemp);
            break;

        default:
            break;
        }
    }