Esempio n. 1
0
        private void LoadCreatures()
        {
            List <AuroraGIT.ACreature> creatures = git.CreatureList;

            GameObject parent = new GameObject("Creatures");

            parent.transform.SetParent(area.transform);

            foreach (AuroraGIT.ACreature c in creatures)
            {
                loader.AddAction(() =>
                {
                    Vector3 position = new Vector3(c.XPosition, c.ZPosition, c.YPosition);

                    //character orientation is stored as a vector2 which describes an angle to rotate around
                    //float x = c.XOrientation, y = c.YOrientation;
                    //float bearing = Mathf.Tan(x / y);
                    //Quaternion rotation = Quaternion.Euler(0, bearing * Mathf.Rad2Deg * -1, 0);

                    float x = c.XOrientation;
                    float y = c.YOrientation;
                    Vector3 lookDirection = new Vector3(x, 0, y);

                    Creature creature = Resources.LoadCreature(c.TemplateResRef, c);
                    creature.gameObject.transform.position = position;
                    creature.gameObject.transform.LookAt(creature.gameObject.transform.position + 10 * lookDirection);
                    creature.gameObject.tag = "Creature";

                    creature.transform.SetParent(parent.transform);
                    creature.transform.name = ((AuroraUTC)creature.template).Tag;
                    SetLayerRecursive(creature.gameObject, LayerMask.NameToLayer("Creature"));

                    //Debug.Log(character.template);
                    stateManager.AddObject(((AuroraUTC)creature.template).Tag, creature);
                });
            }
        }