コード例 #1
0
 /// <summary>
 /// Func create gameObject in random position
 /// </summary>
 /// <returns>gameObject</returns>
 private GameObject createGameObject(GameObject gameObject)
 {
     try
     {
         GameObject gameObjectHolder = GameObject.Find(gameObject.name);
         if (gameObjectHolder == null)
         {
             gameObjectHolder      = new GameObject();
             gameObjectHolder.name = gameObject.name;
         }
         Node coordinates = getRandomCoordinates();
         if (coordinates.walkable)
         {
             GameObject player =
                 Instantiate(gameObject,
                             new Vector3(coordinates.worldPosition.x, 0.3f, coordinates.worldPosition.z),
                             Quaternion.identity) as GameObject;
             player.transform.parent = gameObjectHolder.transform;
             return(player);
         }
     }
     catch (System.Exception e)
     {
         _logger.LogException(e);
     }
     return(null);
 }
コード例 #2
0
 static public int LogException(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.Logger self = (UnityEngine.Logger)checkSelf(l);
             System.Exception   a1;
             checkType(l, 2, out a1);
             self.LogException(a1);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 3)
         {
             UnityEngine.Logger self = (UnityEngine.Logger)checkSelf(l);
             System.Exception   a1;
             checkType(l, 2, out a1);
             UnityEngine.Object a2;
             checkType(l, 3, out a2);
             self.LogException(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function LogException to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #3
0
 private void Start()
 {
     _logger = new UnityEngine.Logger(new LabyrinthLogHandler());
     _logger.Log(_tag, "SessionResultAnimation Start.");
     try
     {
         text = GetComponent <Text>();
         if (Menu.SessionList == null)
         {
             text.text = "No Data";
             return;
         }
         else
         if (Menu.SessionList.Sessions.Count != 0)
         {
             text.text = getLastObjectInformation();
         }
         else
         {
             text.text = "No Data";
         }
     }
     catch (System.Exception e)
     {
         _logger.LogException(e);
     }
 }
コード例 #4
0
 static public int LogException(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.Logger self = (UnityEngine.Logger)checkSelf(l);
             System.Exception   a1;
             checkType(l, 2, out a1);
             self.LogException(a1);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 3)
         {
             UnityEngine.Logger self = (UnityEngine.Logger)checkSelf(l);
             System.Exception   a1;
             checkType(l, 2, out a1);
             UnityEngine.Object a2;
             checkType(l, 3, out a2);
             self.LogException(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function LogException to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
コード例 #5
0
 static public int LogException__Exception(IntPtr l)
 {
     try {
         UnityEngine.Logger self = (UnityEngine.Logger)checkSelf(l);
         System.Exception   a1;
         checkType(l, 2, out a1);
         self.LogException(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #6
0
 public void Save()
 {
     try
     {
         _logger.Log(_tag, "SessionList Save.");
         var serializer = new XmlSerializer(typeof(SessionList));
         using (var stream = new FileStream(Path.Combine(Application.dataPath, "session_list.xml"), FileMode.Create))
         {
             serializer.Serialize(stream, this);
         }
     }
     catch (System.Exception e)
     {
         _logger.LogException(e);
     }
 }
コード例 #7
0
ファイル: CoinUpdate.cs プロジェクト: BartoshMaxim/Labyrinth
 void OnCollisionEnter(Collision col)
 {
     try
     {
         if (col.gameObject.name == "Player(Clone)")
         {
             _session.Player.AddCoin(Income);
             _session.RemoveCoin(Id);
             Destroy(this.gameObject);
         }
     }
     catch (System.Exception e)
     {
         _logger.LogException(e);
     }
 }
コード例 #8
0
ファイル: Coin.cs プロジェクト: BartoshMaxim/Labyrinth
 public Coin(GameObject coin, Func <GameObject, GameObject> create)
 {
     try
     {
         _logger = new UnityEngine.Logger(new LabyrinthLogHandler());
         _logger.Log(tag, "Coin " + _id + " Create.");
         _coin = coin;
         Id    = id;
         id++;
         _coin.GetComponent <CoinUpdate>().Income = Income;
         create(_coin);
     }
     catch (System.Exception e)
     {
         _logger.LogException(e);
     }
 }
コード例 #9
0
 private void Start()
 {
     _logger = new UnityEngine.Logger(new LabyrinthLogHandler());
     _logger.Log(_tag, "SessionResultAnimation Start.");
     try
     {
         if (File.Exists(Path.Combine(Application.dataPath, "session_list.xml")))
         {
             SessionList = SessionList.Load();//read data from xml
         }
         else
         {
             SessionList = new SessionList();
         }
     }
     catch (System.Exception e)
     {
         _logger.LogException(e);
     }
 }
コード例 #10
0
    public static int LogException(IntPtr l)
    {
        int result;

        try
        {
            int num = LuaDLL.lua_gettop(l);
            if (num == 2)
            {
                UnityEngine.Logger logger = (UnityEngine.Logger)LuaObject.checkSelf(l);
                Exception          exception;
                LuaObject.checkType <Exception>(l, 2, out exception);
                logger.LogException(exception);
                LuaObject.pushValue(l, true);
                result = 1;
            }
            else if (num == 3)
            {
                UnityEngine.Logger logger2 = (UnityEngine.Logger)LuaObject.checkSelf(l);
                Exception          exception2;
                LuaObject.checkType <Exception>(l, 2, out exception2);
                UnityEngine.Object context;
                LuaObject.checkType <UnityEngine.Object>(l, 3, out context);
                logger2.LogException(exception2, context);
                LuaObject.pushValue(l, true);
                result = 1;
            }
            else
            {
                LuaObject.pushValue(l, false);
                LuaDLL.lua_pushstring(l, "No matched override function LogException to call");
                result = 2;
            }
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
コード例 #11
0
        private void Start()
        {
            _logger = new UnityEngine.Logger(new LabyrinthLogHandler());
            _logger.Log(_tag, "Statistics Start.");

            try
            {
                _textResult = GetComponent <Text>();

                if (File.Exists(Path.Combine(Application.dataPath, "session_list.xml")))
                {
                    _textResult.text = getTable(SessionList.Load().Sessions);
                }
                else
                {
                    _textResult.text = "No data";
                }
            }
            catch (System.Exception e)
            {
                _logger.LogException(e);
            }
        }
コード例 #12
0
 public void Exception(System.Exception e)
 {
     logger.LogException(e, context);
 }
コード例 #13
0
ファイル: Loader.cs プロジェクト: CliftonMarien/Kopernicus
            // Generates the system prefab from the configuration 
            void IParserEventSubscriber.PostApply(ConfigNode node)
            {
                // Dictionary of bodies generated
                Dictionary<string, Body> bodies = new Dictionary<string, Body>();

                // Load all of the bodies
                foreach (ConfigNode bodyNode in node.GetNodes(bodyNodeName)) 
                {
                    // Create a logger for this body
                    Logger bodyLogger = new Logger(bodyNode.GetValue("name") + ".Body");
                    bodyLogger.SetAsActive();

                    // Attempt to create the body
                    try
                    {
                        currentBody = new Body();
                        Parser.LoadObjectFromConfigurationNode(currentBody, bodyNode);
                        bodies.Add(currentBody.name, currentBody);
                        Logger.Default.Log("[Kopernicus]: Configuration.Loader: Loaded Body: " + currentBody.name);
                    } 
                    catch (Exception e) 
                    {
                        bodyLogger.LogException(e);
                        Logger.Default.Log("[Kopernicus]: Configuration.Loader: Failed to load Body: " + bodyNode.GetValue("name"));
                    }

                    // Restore default logger
                    bodyLogger.Flush ();
                    Logger.Default.SetAsActive ();
                }

                // Load all of the asteroids                
                foreach (ConfigNode asteroidNode in node.GetNodes(asteroidNodeName))
                {
                    // Create a logger for this asteroid
                    Logger logger = new Logger(asteroidNode.GetValue("name") + ".Asteroid");
                    logger.SetAsActive();

                    // Attempt to create the Asteroid
                    try
                    {
                        Asteroid asteroid = Parser.CreateObjectFromConfigNode<Asteroid>(asteroidNode);
                        DiscoverableObjects.asteroids.Add(asteroid);
                        Logger.Default.Log("[Kopernicus]: Configuration.Loader: Loaded Asteroid: " + asteroid.name);
                    }
                    catch (Exception e)
                    {
                        logger.LogException(e);
                        Logger.Default.Log("[Kopernicus]: Configuration.Loader: Failed to load Asteroid: " + asteroidNode.GetValue("name"));
                    }

                    // Restore default logger
                    logger.Flush();
                    Logger.Default.SetAsActive();
                }

                // Glue all the orbits together in the defined pattern
                foreach (KeyValuePair<string, Body> body in bodies) 
                {
                    // If this body is in orbit around another body
                    if(body.Value.orbit != null)
                    {
                        // Get the Body object for the reference body
                        Body parent = null;
                        if(!bodies.TryGetValue(body.Value.orbit.referenceBody, out parent))
                        {
                            throw new Exception("\"" + body.Value.orbit.referenceBody + "\" not found.");
                        }

                        // Setup the orbit of the body
                        parent.generatedBody.children.Add(body.Value.generatedBody);
                        body.Value.generatedBody.orbitDriver.referenceBody = parent.generatedBody.celestialBody;
                        body.Value.generatedBody.orbitDriver.orbit.referenceBody = parent.generatedBody.celestialBody;
                    }

                    // Parent the generated body to the PSystem
                    body.Value.generatedBody.transform.parent = systemPrefab.transform;
                }

                // Elect root body
                systemPrefab.rootBody = bodies.First(p => p.Value.orbit == null).Value.generatedBody;

                // Sort by distance from parent (discover how this effects local bodies)
                RecursivelySortBodies (systemPrefab.rootBody);

                // Fix doubled flightGlobals
                List<int> numbers = new List<int>() { 0 };
                int index = bodies.Sum(b => b.Value.generatedBody.flightGlobalsIndex);
                PatchFGI(ref numbers, ref index, systemPrefab.rootBody);
            }