Beispiel #1
0
        public GameObject CreateObjectToAdd(string[] commandParts)
        {
            GameObject newObject = null;
            int        x = 0; int y = 0;
            var        toInit = new List <Func <string, bool> >()
            {
                s => int.TryParse(s, out x),
                s => int.TryParse(s, out y)
            };
            bool ifParsed = commandParts.Count() > 3?
                            ifParsed = commandParts.Skip(3)
                                       .Select((s, i) => toInit[i](s))
                                       .Aggregate((f, s) => f && s):ifParsed = true;

            if (ifParsed)
            {
                var name = commandParts[2];
                try
                {
                    newObject          = factory.CreateGameObject(name);
                    newObject.Position = new Vector3(x, y, 0);
                }
                catch (Ninject.ActivationException e)
                {
                    Console.WriteLine("nonexistent gameobject");
                }
                gameObjectsStack.Push(newObject);
            }
            else
            {
                Console.WriteLine("some mistake in scene command(parameters of object)");
            }
            return(newObject);
        }