示例#1
0
 static public FireController getInstance()
 {
     if (instance == null)
     {
         instance = GameObject.Find("GlobalController").AddComponent <FireController>();
     }
     return(instance);
 }
示例#2
0
        void AskCreate(NetworkMessageInfo info)
        {
            //       MoveInfo += "\n" + "客户" + info.sender + ":Asked create";
            PersonControllerIns = GameObject.Find("PersonController");
            personList          = PersonControllerIns.GetComponent <PersonController>().getPersonList();
            string ManName;

            for (int i = 0; i < personList.Count; i++)
            {
                ManName = personList[i].getPointer().name;
                ManName = getAManName(ManName);
                MainRoom.GetComponent <NetworkView>().RPC("RequestCreate2", RPCMode.All, ManName, personList[i].getX(), personList[i].getY(), personList[i].getPointer().transform.rotation);
            }
            List <GameObject> fires = FireController.getInstance().getFires();

            Debug.Log("fireCount:" + fires.Count);
            for (int j = 0; j < fires.Count; j++)
            {
                Debug.Log("fire" + j);
                if (fires[j].name == "Fire(Clone)")
                {
                    MainRoom.GetComponent <NetworkView>().RPC("SyncFire2", RPCMode.All, "Fire", (int)fires[j].transform.position.x, (int)fires[j].transform.position.z, Quaternion.identity);
                }
                else
                {
                    MainRoom.GetComponent <NetworkView>().RPC("SyncFire2", RPCMode.All, "fx_fire_a", (int)fires[j].transform.position.x, (int)fires[j].transform.position.z, Quaternion.identity);
                }
            }

            for (int k = 0; k < Players.Count; k++)
            {
                if (Players[k] == null)
                {
                    MainRoom.GetComponent <NetworkView>().RPC("AddPlayerNone", RPCMode.All);
                }
                else if (Players[k].name == "Man(Clone)" || Players[k].name == "Man2(Clone)" || Players[k].name == "Man3(Clone)" || Players[k].name == "Man4(Clone)" || Players[k].name == "Man5(Clone)" || Players[k].name == "Man6(Clone)")//needchange
                {
                    ManName = getAManName(Players[k].name);
                    MainRoom.GetComponent <NetworkView>().RPC("AddPlayerDied", RPCMode.All, ManName, Players[k].transform.position, Players[k].transform.rotation);
                }
                else
                {
                    ManName = Players[k].name;
                    ManName = getAPlayerName(ManName);
                    MainRoom.GetComponent <NetworkView>().RPC("AddPlayer", RPCMode.All, ManName, Players[k].transform.position, Players[k].transform.rotation);
                }
            }
            Vector3 HumanPos = PersonControllerIns.GetComponent <PersonController>().setHuman();

            ManName = getARandomMan();
            Players.Add((GameObject)Instantiate(Resources.Load(ManName), HumanPos, Quaternion.identity));
            Players[Players.Count - 1].AddComponent <HumanController>();
            Players[Players.Count - 1].GetComponent <HumanController>().SetIndex(Players.Count - 1);    //new
            MainRoom.GetComponent <NetworkView>().RPC("AddPlayer2", RPCMode.Others, ManName, HumanPos);
            AllPerson += 1;
        }
        public void moveNext()
        {
            bool isMove = true;

            if (callTimes == 0 || callTimes % CALLPERCOUNT >= CALLPERCOUNT - 1)
            {
                FireController.getInstance().handleFireNodes(callTimes);
                int i = 0;
                foreach (Point exit in exits)
                {
                    MoveController.getInstance().DijkstraShortestPath(exit.x * FloorPlanManager.getInstance().getHeight() + exit.y, i);
                    i++;
                }
                for (int j = 0; j < personList.Count; j++)
                {
                    personList[j].setExitIndex(getNearestExitIndex(personList[j].getPosition()));
                }
            }
            for (int i = 0; i < personList.Count; i++)
            {
                handleAloneScare(personList[i]);
                //if person's scare value > 80, then he will random a avaliable direction
                if (personList[i].isAffectedByScare())
                {
                    isMove = personList[i].moveNextRandom(i);
                    personList[i].decreaseScareValue();
                }
                else
                {
                    if (getNeighborNum(personList[i]) > 30)
                    {
                        //寻找别的道路
                        personList[i].changeExitIndex();
                        isMove = personList[i].moveNext(i);
                    }
                    else
                    {
                        isMove = personList[i].moveNext(i);
                    }
                }
                if (isMove)
                {
                    updateContainerNum(new Point(personList[i].getOriginX(), personList[i].getOriginY()), personList[i].getPosition());
                }
            }
            ++callTimes;
            UpdateMap();
        }