Пример #1
0
        void LuaNPCScript(GameObject obj)
        {
            if (Time.time - time > interDeltime)
            {
                time = Time.time;
                MapPlayer  mapPlayer  = GetComponent <MapPlayer>();
                MapMonster mapMonster = GetComponent <MapMonster>();
                if (mapPlayer != null && mapPlayer.enabled)
                {
                    mapPlayer.UpdateDirection((obj.transform.position - transform.position).normalized, true);
                }
                else if (mapMonster != null && mapMonster.enabled)
                {
                    mapMonster.UpdateDirection((obj.transform.position - transform.position).normalized);
                }

                string fileName = (script == null) ? "guide/" + LuaTextName + ".lua" : script.name;
                if (luaThreadEval == null)
                {
                    luaThreadEval = LuaController.GetLuaValue <LuaThreadEval>("ThreadEvalWithGameObject");
                }
                if (luaThreadEval != null)
                {
                    luaThreadEval(fileName, fileName, this, values);
                }
                else
                {
                    LuaController.DoFile(fileName, values);
                }
            }
        }
Пример #2
0
 void Start()
 {
     mapPlayer = GetComponent <MapPlayer>();
     Nav       = gameObject.GetComponent <NavMeshAgent>();
     if (Nav)
     {
         Nav.enabled = false;
     }
 }
Пример #3
0
        public void ControllPlayer(long id)
        {
            controlled_id = id;
            MapPlayer player = Get(id);

            if (player != null)
            {
                playerCamera.target = player.transform;
            }
        }
Пример #4
0
 public Character(GameObject _obj)
 {
     obj     = _obj;
     player  = obj.GetComponent <MapPlayer>();
     agent   = obj.GetComponent <NavMeshAgent>();
     pause   = false;
     moving  = false;
     target  = 0;
     process = 0;
 }
Пример #5
0
        public void Remove(long id)
        {
            MapPlayer player;

            if (!players.TryGetValue(id, out player))
            {
                return;
            }

            players.Remove(id);

            if (id == controlled_id)
            {
                self_player = null;
                if (playerCamera != null)
                {
                    playerCamera.target = null;
                }
            }

            Destroy(player.gameObject);
        }
Пример #6
0
        public virtual void Interact(GameObject obj)
        {
            if (Time.realtimeSinceStartup - last_interact_time < interact_protect_time)
            {
                return;
            }

            last_interact_time = Time.realtimeSinceStartup;
            MapPlayer  mapPlayer  = GetComponent <MapPlayer>();
            MapMonster mapMonster = GetComponent <MapMonster>();

            if (mapPlayer != null && mapPlayer.enabled)
            {
                mapPlayer.UpdateDirection((obj.transform.position - transform.position).normalized, true);
            }
            else if (mapMonster != null && mapMonster.enabled)
            {
                mapMonster.UpdateDirection((obj.transform.position - transform.position).normalized);
            }
            else
            {
            }

            string fileName = (script == null) ? "guide/" + LuaTextName + ".lua" : script.name;

            if (luaThreadEval == null)
            {
                luaThreadEval = LuaController.GetLuaValue <LuaThreadEval>("ThreadEvalWithGameObject");
            }
            if (luaThreadEval != null)
            {
                luaThreadEval(fileName, fileName, this, values);
            }
            else
            {
                LuaController.DoFile(fileName, values);
            }
        }
Пример #7
0
        public MapPlayer AddMember(long id, GameObject parent)
        {
            MapPlayer player = Add(id);

            if (player.enabled)
            {
                //float x = parent.transform.localPosition.x + 0.5f;
                //player.gameObject.transform.localPosition = new Vector3(x,parent.transform.localPosition.y,parent.transform.localPosition.z);
                player.GetComponent <NavMeshAgent> ().enabled = false;
                // player.enabled = false;
            }
            FollowMovement3d Fol = player.gameObject.GetComponent <FollowMovement3d> ();

            if (!Fol)
            {
                Fol = player.gameObject.AddComponent <FollowMovement3d> ();
            }
            else
            {
                Fol.enabled = true;
            }
            Fol.TargetTF = parent.transform;
            return(player);
        }
Пример #8
0
        public MapPlayer Add(long id)
        {
            MapPlayer player;

            if (players.TryGetValue(id, out player))
            {
                return(player);
            }

            if (playerPrefabobj == null)
            {
                return(null);
            }

            var obj = Instantiate <GameObject>(playerPrefabobj, transform);

            player = obj.GetComponent <MapPlayer>();
            if (player == null)
            {
                return(null);
            }

            players[id] = player;
            player.id   = id;
            player.gameObject.SetActive(true);

            if (id == controlled_id)
            {
                self_player = player;
                if (playerCamera != null)
                {
                    playerCamera.target = player.gameObject.transform;
                }
            }
            return(player);
        }
Пример #9
0
        IEnumerator SetDirection(MapPlayer player, int direction)
        {
            yield return(new WaitForSeconds(0.1f));

            player.SetDirection(direction);
        }