Exemple #1
0
 public void UseEnvironmentCollectionToAddANewGenFormEnvironment()
 {
     try
     {
         var genEnv = EnvironmentFactory.CreateGenFormEnvironment("Test", "Test", "Test", "Test");
         Isolate.WhenCalled(() => _environments.Add(null)).IgnoreCall();
         _genFormEnvironments.Add(genEnv);
         Isolate.Verify.WasCalledWithAnyArguments(() => _environments.Add(null));
     }
     catch (System.Exception e)
     {
         Assert.Fail(e.ToString());
     }
 }
    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;
        }
    }
        public void UseEnvironmentSettingsToAdAnEnvironment()
        {
            var env = new Environment("Test", "Test");

            env.AddSetting("Test", "Test");

            _source   = new TestSource();
            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            Isolate.WhenCalled(() => _settings.Add(null)).IgnoreCall();
            col.Add(env);
            Isolate.Verify.WasCalledWithAnyArguments(() => _settings.Add(null));
        }
    public void AddSpawnedEnvironment(Point point, EnviromentalUnit unit)
    {
        if (EnvironmentCollection.ContainsKey(point) || EnvironmentCollection.ContainsValue(unit))
        {
            Debug.LogError($"[EnvironmentManager] Envrionmental Unit Already Exists. {unit.name} {unit.WorldPosition}, Conflicting Unit: {EnvironmentCollection[point].name} {EnvironmentCollection[point].WorldPosition}", unit);
            return;
        }

        if (AddUnitToMap(point, unit))
        {
            EnvironmentCollection.Add(point, unit);
            return;
        }

        Debug.LogError("[EnvironmentManager] Failed setting environment");
    }
        public IDeploymentInfo ParseDeploymentInfo(StreamReader streamReader)
        {
            MdlScanner scanner = new MdlScanner(new SourceReader(streamReader));
            scanner.RegisterKeyword("deployment");
            scanner.RegisterKeyword("environment");

            IMdlParser mdlParser = new MdlParser(scanner);

            IDeploymentNode deploymentNode = (IDeploymentNode)mdlParser.Parse();
            EnvironmentCollection environments = new EnvironmentCollection();

            foreach(IEnvironmentNode environmentNode in deploymentNode.ChildNodes)
            {
                environments.Add(ParseEnvironment(environmentNode));
            } // foreach

            return new DeploymentInfo(environments);
        }
Exemple #6
0
        public BaseObject CreateObject(ObjectID objectID)
        {
            if (objectID == ObjectID.NullObjectID || objectID == ObjectID.AnyObjectID)
            {
                throw new ArgumentException();
            }

            if (m_objects.Contains(objectID))
            {
                throw new Exception();
            }

            var ob = ConstructObject(objectID);

            m_objects.Add(ob);

            m_rootObjects.Add(ob);

            var env = ob as EnvironmentObject;

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

            var movable = ob as MovableObject;

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

            ob.Destructed += ObjectDestructed;

            return(ob);
        }
        public void UseEnvironmentSettingsToAdAnEnvironment()
        {
            var env = new Environment("Test", "Test");
            env.AddSetting("Test", "Test");

            _source = new TestSource();
            _settings = new EnvironmentSettingsCollection(_source);
            var col = new EnvironmentCollection(_settings);

            Isolate.WhenCalled(() => _settings.Add(null)).IgnoreCall();
            col.Add(env);
            Isolate.Verify.WasCalledWithAnyArguments(() => _settings.Add(null));
        }