Esempio n. 1
0
 public void ActivateSingleNode(PlayerNode node)
 {
     activatedNodes.Clear();
     activatedNodes.Add(node);
     node.activate();
     zoneManager.CheckZones();
 }
Esempio n. 2
0
    //deposit all luggages being held
    protected override void Interact()
    {
        if (toggle)
        {
            //get player's destination
            PlayerNode destination = luggageOwner.GetComponentInChildren <PlayerNode>();

            //check if player will be issued a ticket for losing luggage
            Player receiver = Player.Instance;
            if (!receiver.GetItemFrom(this, 1, content, out List <ItemTransferrable> items, luggageOwner))
            {
                destination.gameObject.AddComponent <LostLuggageTicket>();
                destination.SetTicket();
            }

            Player.Instance.GetComponent <PlayerController>().TransportPlayer(destination.GetPositionInTileMap());

            //restart toggle and customer
            toggle       = false;
            luggageOwner = null;
        }
        else
        {
            Player giver = Player.Instance;
            giver.DropItemTo(this, content);
        }
    }
Esempio n. 3
0
 public void InitBoard()
 {
     if (PlayerNode != null)
     {
         PlayerNode.InitNode();
     }
 }
Esempio n. 4
0
        private string runInstructions(string instructions, PlayerNode player)
        {
            String[] instructionList = instructions.Split(' ');
            string   instruction     = instructionList[0];

            switch (instruction)
            {
            case "heal":
                return(HealPlayer(instructionList[1]));

            case "question":
                QuestionPlayer(instructionList[1], player);
                return(string.Format("questions {0}", instructionList[1]));

            case "kill":
                VotePlayer(instructionList[1]);
                return(string.Empty);

            case "talk":
                return(string.Format("Player {0} says {1}", player.playerName, string.Join(" ", instructionList.Where(s => !s.Equals("talk")))));

            case "accuse":
                VotePlayer(instructionList[1]);
                return(string.Format("Player {0} accuses {1}", player.playerName, instructionList[1]));

            default:
                return(string.Format("Player {0} passes", player.playerName));
            }
        }
Esempio n. 5
0
    public override void FireWeapon()
    {
        var ray = GetNode <RayCast>("Ray_Cast");

        ray.ForceRaycastUpdate();

        if (ray.IsColliding())
        {
            var body = ray.GetCollider();
            if (body == PlayerNode)
            {
            }
            else if (body.HasMethod("BulletHit"))
            {
                if (body is RigidBodyHitTest)
                {
                    var aBody = body as RigidBodyHitTest;
                    aBody.BulletHit(DAMAGE, ray.GlobalTransform);
                }
                else if (body is Target)
                {
                    var aBody = body as Target;
                    aBody.BulletHit(DAMAGE, ray.GlobalTransform);
                }
                else if (body is TurretBodies turret)
                {
                    turret.BulletHit(DAMAGE, GlobalTransform.origin);
                }
            }
        }

        AmmoInWeapon -= 1;
        PlayerNode.CreateSound("Rifle_shot", ray.GlobalTransform.origin);
    }
Esempio n. 6
0
 void Awake()
 {
     instance   = this;
     rend       = GetComponent <Renderer> ();
     startColor = rend.material.color;
     hitColor   = startHitColor;
 }
Esempio n. 7
0
    void SavePlayer()
    {
        CreatePlayerNode();

        PlayerNode player = new PlayerNode(GetXmlNode(XmlNodes.Player.player));

        player.SetPosition(SingletonManager.Player.GetComponent <Transform>().position);

        // y rotation is from player, x rotation is from camera...
        Vector3 rotationPlayer = SingletonManager.Player.GetComponent <Transform>().eulerAngles;

        player.SetRotation(new Vector3(Camera.main.transform.eulerAngles.x, rotationPlayer.y, rotationPlayer.z));

        // Debug.Log("Camera : " + Camera.main.transform.eulerAngles.x);
        // Debug.Log("Player : " + rotationPlayer.y);

        float oxygen = SingletonManager.Player.GetComponent <PlayerOxygen>().m_current;

        player.SetOxygen(oxygen);

        float battery = SingletonManager.Player.GetComponent <PlayerBattery>().m_current;

        player.SetBattery(battery);

        player.SetFlashLight(FlashLight.GetInstance().m_hasBeenPickedUp);
    }
Esempio n. 8
0
    //Sent by newly connected clients, recieved by server
    void TellServerOurName(string name, NetworkMessageInfo info)
    {
        PlayerNode newEntry = new PlayerNode();

        newEntry.playerName    = name;
        newEntry.networkPlayer = info.sender;
        playerList.Add(newEntry);
    }
Esempio n. 9
0
        public int sampleGame(string command)
        {
            PlayerNode player      = players[0];
            int        beta        = (int)((Constants.WEREWOLF_NUMBER * 5 + Constants.SEER_NUMBER * 4 + Constants.DOCTOR_NUMBER * 3 + Constants.VILLAGER_NUMBER) * 0.75);
            int        alpha       = -beta;
            int        gameUtility = player.PlayGame(this, alpha, beta, Constants.DEPTH_LIMIT, command);

            return(gameUtility);
        }
Esempio n. 10
0
    public void OnPlayerConnected(NetworkPlayer player)
    {
        numPlayers++;
        PlayerNode newEntry = new PlayerNode();

        newEntry.playerSpawn   = null;
        newEntry.networkPlayer = player;
        playerList.Add(newEntry);
    }
Esempio n. 11
0
    //Sent by newly connected clients, recieved by server
    void  TellServerOurName(string name, NetworkMessageInfo info)
    {
        PlayerNode newEntry = new PlayerNode();

        newEntry.PlayerName    = name;
        newEntry.NetworkPlayer = info.sender;
        playerList.Add(newEntry);

        addGameChatMessage(name + " joined the chat");
    }
Esempio n. 12
0
    public void GenerateNewNode(string name)
    {
        GameObject newNode = Instantiate(nodeObj);

        newNode.transform.SetParent(content.transform);
        PlayerNode newPlayerNode = newNode.GetComponent <PlayerNode> ();

        newPlayerNode.Initialize(this, playerNodeList.Count + 1, name);
        playerNodeList.Add(newPlayerNode);
    }
Esempio n. 13
0
 public bool IsActivated(PlayerNode node)
 {
     if (activatedNodes.Contains(node))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 14
0
 private void OnReachPlayer()
 {
     playerStats.TakeDamage(attackDamage);
     Instantiate(deathEffect, transform.position, Quaternion.identity);
     PlayerNode.HitColorEffect();
     Die();
     if (isSabator)
     {
         playerStats.specialBullets -= specialBulletDeduction;
     }
 }
Esempio n. 15
0
    public void DeleteNode(PlayerNode target)
    {
        int addr = playerNodeList.IndexOf(target);

        playerNodeList.RemoveAt(addr);
        for (int i = addr; i < playerNodeList.Count; i++)
        {
            playerNodeList [i].Setnum(i + 1);
        }
        Destroy(target.gameObject);
    }
Esempio n. 16
0
	//server side
	void OnServerInitialized() {

		ShowChatWindow();

		PlayerNode newNode = new PlayerNode();
		newNode.playerName = playerName;
		newNode.networkPlayer = Network.player;
		playerList.Add(newNode);

		addGameChatMessage(playerName + "joined the game.");
	}
Esempio n. 17
0
    //Server function
    void  OnServerInitialized()
    {
        ShowChatWindow();
        //I wish Unity supported sending an RPC on the server to the server itself :(
        // If so; we could use the same line as in "OnConnectedToServer();"
        PlayerNode newEntry = new PlayerNode();

        newEntry.PlayerName    = playerName;
        newEntry.NetworkPlayer = Network.player;
        playerList.Add(newEntry);
        addGameChatMessage(playerName + " joined the chat");
    }
Esempio n. 18
0
    //server side
    void OnServerInitialized()
    {
        ShowChatWindow();

        PlayerNode newNode = new PlayerNode();

        newNode.playerName    = playerName;
        newNode.networkPlayer = Network.player;
        playerList.Add(newNode);

        addGameChatMessage(playerName + "joined the game.");
    }
Esempio n. 19
0
    void SendPlayersOnGame(NetworkPlayer playerC, string playernameC, string colorC)
    {
        //if(GetPlayerNode(playerC)!=null)
        {
            //Debug.Log("aquiiiii"+playernameC);
            PlayerNode newEntry = new PlayerNode();

            newEntry.playerName = playernameC;
            newEntry.player     = playerC;
            newEntry.color      = colorC;

            playerList.Add(newEntry);
        }
    }
Esempio n. 20
0
    public override void FireWeapon()
    {
        var     clone     = _bulletScene.Instance() as BulletScript;
        Spatial sceneRoot = GetTree().Root.GetChildren()[0] as Spatial;

        sceneRoot.AddChild(clone);

        clone.GlobalTransform = this.GlobalTransform;
        clone.Scale           = new Vector3(4, 4, 4);
        clone.BULLET_DAMAGE   = DAMAGE;

        AmmoInWeapon -= 1;

        PlayerNode.CreateSound("Pistol_shot", this.GlobalTransform.origin);
    }
Esempio n. 21
0
        private string accuseLogic()
        {
            string result = "No player was accused this round";

            //Accuse Player Logic
            PlayerNode accusedPlayer = getMostVotedPlayer();

            if (accusedPlayer != null)
            {
                result = string.Format("Player {0} was accused and is now dead", accusedPlayer.playerName);
                accusedPlayer.playerDead = true;
            }

            return(result);
        }
Esempio n. 22
0
    private void OnWrongHit(Enemy hitEnemy)
    {
        if (hitEnemy.isSabator)
        {
            playerStats.specialBullets -= hitEnemy.specialBulletDeduction;
        }

        if (hitEnemy.poisonEffect != null)
        {
            GameObject i = Instantiate(hitEnemy.poisonEffect, transform.position, Quaternion.identity) as GameObject;
            Destroy(i.gameObject, 3f);
        }
        playerStats.TakeDamage(hitEnemy.errorShotDamage);
        PlayerNode.HitColorEffect();
    }
Esempio n. 23
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        customer      = animator.gameObject.GetComponent <Customer>();
        playerNode    = customer.GetComponentInChildren <PlayerNode>();
        patience      = customer.patience;
        satisfaction  = customer.satisfaction;
        renderer      = customer.GetComponent <SpriteRenderer>();
        this.animator = animator;
        receiver      = customer;

        SubscribeEvents();

        //turn the patience counter back on
        patience.SetPatienceInteractibility(true);
    }
Esempio n. 24
0
File: Map.cs Progetto: hilliam/Mud
    public static Map ReadMap(PlayerNode player)
    {
        var mapa = new Map();
        string stringMapa = "";
        try
            {
                //Pass the file path and file name to the StreamReader constructor
                //StreamReader sr = new StreamReader("J:\\map2.txt", System.Text.Encoding.ASCII);

                //Read the first line of text
                //var line = sr.ReadLine();

                // create reader and open file
                using (StreamReader reader = new StreamReader("J:\\map2.txt", System.Text.Encoding.ASCII))
                {
                    // read all contents
                    stringMapa = reader.ReadToEnd();
                }

                //Continue to read until you reach end of file
        //				while (line != null)
        //				{
        //					//write the lie to console window
        //					//Console.WriteLine(line);
        //					stringMapa += line;
        //					//networkView.RPC("SendMsgToClient", player.networkPlayer, player.networkPlayer, line);
        //					//Read the next line
        //					line = sr.ReadLine();
        //				}

                //close the file
                //reader.Close();
                //Console.ReadLine();
                mapa.mapString = stringMapa;
            }
            catch(Exception e)
            {
                //networkView.RPC("SendMsgToClient", player.networkPlayer, player.networkPlayer, "Exception: " + e.Message);
                //Console.WriteLine("Exception: " + e.Message);
            }
            finally
            {
             	//networkView.RPC("SendMsgToClient", player.networkPlayer, player.networkPlayer, "Executing finally block.");
                //Console.WriteLine("Executing finally block.");
            }
        return mapa;
        //System.IO.StreamReader reader = new System.IO.StreamReader(fileName,  System.Text.Encoding.ASCII);
    }
Esempio n. 25
0
        private string killLogic()
        {
            string result = "No player was killed this round";

            //Kill Player Logic
            PlayerNode killedPlayer = getMostVotedPlayer();

            //This should never happen, just for testing sake
            if (killedPlayer != null)
            {
                result = string.Format("A player was chosen to be killed by the werewolves");
                killedPlayer.playerDead = true;
            }

            return(result);
        }
Esempio n. 26
0
    void TellServerOurName(string name, NetworkPlayer player, string color)
    {
        PlayerNode newEntry = new PlayerNode();

        newEntry.playerName = name;
        newEntry.player     = player;
        newEntry.color      = color;

        playerList.Add(newEntry);

        foreach (PlayerNode entry in playerList)
        {
            networkView.RPC("SendPlayersOnGame", RPCMode.Others, entry.player, entry.playerName, entry.color);
        }

        addGameChatMessage(playerName + " have just joined the chat");
    }
Esempio n. 27
0
        public void MoveRoot(LogarithmicGrid newGrid)
        {
            this.rootNode = (PlayerNode)this.rootNode.Children.Values
                                            .SelectMany(cn => cn.Children)
                                            .First(pn => pn.Grid.Equals(newGrid));

            var sum = this.rootNode.Sum;

            foreach (var lesserSum in this.knownPlayerNodesBySum.Keys.Where(k => k <= sum).ToArray())
            {
                this.knownPlayerNodesBySum.Remove(lesserSum);
            }

            foreach (var lesserSum in this.knownComputerNodesBySum.Keys.Where(k => k < sum).ToArray())
            {
                this.knownComputerNodesBySum.Remove(lesserSum);
            }
        }
Esempio n. 28
0
        public void MoveRoot(LogarithmicGrid newGrid)
        {
            this.rootNode = (PlayerNode)this.rootNode.Children.Values
                            .SelectMany(cn => cn.Children)
                            .First(pn => pn.Grid.Equals(newGrid));

            var sum = this.rootNode.Sum;

            foreach (var lesserSum in this.knownPlayerNodesBySum.Keys.Where(k => k <= sum).ToArray())
            {
                this.knownPlayerNodesBySum.Remove(lesserSum);
            }

            foreach (var lesserSum in this.knownComputerNodesBySum.Keys.Where(k => k < sum).ToArray())
            {
                this.knownComputerNodesBySum.Remove(lesserSum);
            }
        }
Esempio n. 29
0
    public void SetGame(GameInfo game)
    {
        CurrentGame = game;
        List <PlayerInfo> players = game.Players;

        mNodes = new Dictionary <PlayerInfo, PlayerNode>();

        foreach (PlayerInfo player in players)
        {
            PlayerNode bubble = Instantiate(mNodePrefab);
            bubble.transform.SetParent(MainCanvas.transform);
            bubble.RectTransform.anchoredPosition = Vector2.zero;

            bubble.SetPlayer(player);

            mNodes[player] = bubble;
        }

        mArcs = new List <CommanderDamageArc>();

        for (int i = 0; i < players.Count - 1; i++)
        {
            for (int j = i + 1; j < players.Count; j++)
            {
                PlayerNode playerBubble      = mNodes[players[i]];
                PlayerNode otherPlayerBubble = mNodes[players[j]];

                CommanderDamageArc arc = Instantiate(mCommanderDamagePrefab);
                arc.transform.SetParent(MainCanvas.transform);
                //Ensure the arcs render behind the nodes but in front of the background
                arc.transform.SetSiblingIndex(mBackgroundChildrenCount);

                arc.BeginTarget = playerBubble.VisualRectTransform;
                arc.EndTarget   = otherPlayerBubble.VisualRectTransform;

                arc.SetPlayers(players[i], players[j]);

                mArcs.Add(arc);
            }
        }

        Scale();
    }
Esempio n. 30
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);
            // note: i don't advise to do this in a real application
            // i think it's better to just get the node in load and use it here
            // this is for testing
            PlayerNode player = Root.GetChild <PlayerNode>();

            Camera.Position = player.GlobalTransform.Position;

            if (Input.IsDown(Key.Q))
            {
                Camera.Scale *= 1.01f;
            }
            else if (Input.IsDown(Key.E))
            {
                Camera.Scale *= 0.99f;
            }
        }
Esempio n. 31
0
    void OnServerInitialized()
    {
        playerName  = PlayerPrefs.GetString("playerName", "");
        playerColor = PlayerPrefs.GetString("playerColor", "");

        if (playerName == "")
        {
            playerName = "RandomName" + UnityEngine.Random.Range(1, 999);
        }

        ShowChatWindow();
        PlayerNode newEntry = new PlayerNode();

        newEntry.playerName = playerName;
        newEntry.player     = Network.player;
        newEntry.color      = playerColor;

        playerList.Add(newEntry);
        addGameChatMessage(playerName + "have just joined the chat");
    }
Esempio n. 32
0
        private string HealPlayer(string playerName)
        {
            string result = "No player was healed this round\n";

            //Kill Player Logic
            string killedPlayerName = getMostVotedPlayerName();

            if (playerName.Equals(killedPlayerName))
            {
                PlayerNode killedPlayer = getPlayerByName(killedPlayerName);

                //This should never happen, just for testing sake
                if (killedPlayer != null)
                {
                    result       = string.Format("A player was chosen to be healed.\n");
                    healedPlayer = playerName;
                }
            }
            return(result);
        }
Esempio n. 33
0
            private IEnumerable <IPlayerNode> GetChildrenWith2()
            {
                if (this.computedNodesWith2 == null)
                {
                    this.computedNodesWith2 = new List <IPlayerNode>();
                }
                else
                {
                    foreach (var node in this.computedNodesWith2)
                    {
                        yield return(node);
                    }
                }

                if (!this.allNodesWith2Computed)
                {
                    IDictionary <LogarithmicGrid, IPlayerNode> knownPlayerNodesWithSumPlus2;
                    if (!this.SearchTree.knownPlayerNodesBySum.TryGetValue(this.Sum, out knownPlayerNodesWithSumPlus2))
                    {
                        knownPlayerNodesWithSumPlus2 = new Dictionary <LogarithmicGrid, IPlayerNode>();
                        this.SearchTree.knownPlayerNodesBySum.Add(this.Sum, knownPlayerNodesWithSumPlus2);
                    }

                    foreach (var possibleState in this.Grid.NextPossibleStatesWith2().Skip(this.computedNodesWith2.Count))
                    {
                        IPlayerNode playerNode;
                        if (!knownPlayerNodesWithSumPlus2.TryGetValue(possibleState, out playerNode))
                        {
                            playerNode = new PlayerNode(possibleState, this.SearchTree, this.Sum + 2);
                            knownPlayerNodesWithSumPlus2.Add(possibleState, playerNode);
                        }

                        this.computedNodesWith2.Add(playerNode);

                        yield return(playerNode);
                    }
                }

                this.allNodesWith2Computed = true;
            }
Esempio n. 34
0
    void TellServerOurName(string name, NetworkMessageInfo info)
    {
        PlayerNode newEntry = new PlayerNode();
        newEntry.PlayerName = name;
        newEntry.NetworkPlayer = info.sender;
        this.playerList.Add(newEntry);

        this.AddGameChatMessage(name + " joined the chat");
    }
Esempio n. 35
0
 public SearchTree(IHeuristic heuristic, LogarithmicGrid startingGrid)
 {
     this.Heuristic = heuristic;
     this.rootNode = new PlayerNode(startingGrid, this, startingGrid.Sum());
 }
Esempio n. 36
0
 void TellServerOurName(string name, NetworkMessageInfo info)
 {
     PlayerNode newEntry = new PlayerNode();
     newEntry.playerName = name;
     newEntry.player = Network.player;
     playerList.Add(newEntry);
     AddGameChatMessage(name + " has just joined the nebula!");
 }
        private void ComputeNextActions()
        {
            float goalDestinationX = player.Location.X + 983;
            HashSet<int> visited = new HashSet<int>();

            orderedSet = new OrderedBag<PlayerNode>((a, b) => a.Destination((int)goalDestinationX).CompareTo(b.Destination((int)goalDestinationX)));

            PlayerNode initialNode = new PlayerNode(null, sceneTime, 0, PlayerAction.None, player.Clone(), 0);
            orderedSet.Add(initialNode);
            visited.Add((int)initialNode.PlayerElement.Location.X << 10 + (int)initialNode.PlayerElement.Location.Y);

            PlayerNode bestNode = initialNode;
            bool foundBest = false;

            while (orderedSet.Count > 0 && !foundBest)
            {
                PlayerNode current = orderedSet.RemoveFirst();

                if (current.PlayerElement.IsOnGround() && bestNode.Destination((int)goalDestinationX) > current.Destination((int)goalDestinationX))
                {
                    bestNode = current;
                }

                foreach (PlayerAction action in possibleActions)
                {
                    if (action == PlayerAction.Jump && !current.PlayerElement.IsOnGround())
                    {
                        continue;
                    }

                    PlayerElement newPlayer = current.PlayerElement.Clone();
                    newPlayer.IsPlayerAGoat = true;
                    switch (action)
                    {
                        case PlayerAction.None:
                            newPlayer.Stop();
                            break;
                        case PlayerAction.MoveRight:
                            newPlayer.MoveForward();
                            break;
                        case PlayerAction.MoveLeft:
                            newPlayer.MoveBackward();
                            break;
                        case PlayerAction.Jump:
                            newPlayer.Jump();
                            break;
                    }

                    GameTime newTime = IncrementTime(current.Time);
                    newPlayer.Update(newTime);
                    Parallel.ForEach(timeDependentElements, element => element.Update(newTime));
                    HandleInteraction(newPlayer);
                    if (newPlayer.IsDead)
                    {
                        continue;
                    }

                    int hash = ((int)(newPlayer.Location.X * 10) << 7) + (int)newPlayer.Location.Y;
                    if (!visited.Add(hash))
                    {
                        continue;
                    }

                    PlayerNode newNode = new PlayerNode(current, newTime, current.Moves + 1, action, newPlayer, current.Jumps + (action == PlayerAction.Jump ? 1 : 0));
                    if (newPlayer.Location.X > goalDestinationX && newPlayer.IsOnGround() || newPlayer.HasWon)
                    {
                        bestNode = newNode;
                        foundBest = true;
                        break;
                    }
                    orderedSet.Add(newNode);
                }
            }

            orderedSet.Clear();
            if (bestNode == initialNode)
            {
                pendingActions.Enqueue(PlayerAction.None);
            }
            else
            {
                GetActionsFromNode(bestNode);
            }
        }
 public PlayerNode(PlayerNode parent, GameTime time, int moves, PlayerAction action, PlayerElement playerElement, int jumps)
 {
     this.Parent = parent;
     this.Time = time;
     this.Moves = moves;
     this.Action = action;
     this.PlayerElement = playerElement;
     this.Jumps = jumps;
 }
        private void GetActionsFromNode(PlayerNode node)
        {
            if (node.Parent == null)
            {
                return;
            }
            else
            {
                GetActionsFromNode(node.Parent);
            }

            pendingActions.Enqueue(node.Action);
        }
Esempio n. 40
0
 private PlayerNode GetPlayerNode(IPlayer player)
 {
     int playerId = player.ID;
     try
     {
         return playerNodes[playerId];
     }
     catch(KeyNotFoundException)
     {
         return playerNodes[playerId] = new PlayerNode(player);
     }
 }
Esempio n. 41
0
    public static Comands ParseItemCommand(string cmd, ComandsType typeCommands, Room currentRoom, PlayerNode player)
    {
        var retornoComando = new Comands();
        var nomeItem = cmd;
        retornoComando.Comando = "Comando inválido";
        if(typeCommands == ComandsType.UsarItem)
        {
            var openDoor = false;
            foreach (var item in currentRoom.m_ItemsRoom)
            {

                if (item.m_NameItem == nomeItem)
                {
                    var jogadorComItem = player.Inventory.Where(i => i.m_NameItem == nomeItem).Select(s => s.m_NameItem == nomeItem).FirstOrDefault();
                    if(jogadorComItem)
                    {
                        if (item.m_IsUsedItem)
                        {
                            retornoComando.Comando = "Item ja usado.";
                            break;
                        }
                        else
                        {
                            if (item.m_GetItem)
                            {
                                retornoComando.Comando = "Usar item " + nomeItem;
                                item.m_IsUsedItem = true;
                                player.Inventory.Remove(item);

                                break;
                            }
                        }
                    }
                    else{
                 		retornoComando.Comando = "Jogador esta sem o item.";
                        break;
                    }
                }

            }

            retornoComando.IsOpenDoor = currentRoom.m_ItemsRoom.All(a => a.m_IsUsedItem == true);

        }
        else if (typeCommands == ComandsType.PegarItem)
        {
            foreach (var item in currentRoom.m_ItemsRoom)
            {
                if (item.m_NameItem == nomeItem)
                {
                    if (item.m_GetItem)
                    {
                        retornoComando.Comando = "Item já foi pego.";
                        break;
                    }
                    else
                    {
                        retornoComando.Comando = "Item " + nomeItem +" adquerido.";
                        item.m_GetItem = true;
                        item.m_Collectable = false;
                        //item = GameObject.GetComponent<Room>();
                        player.Inventory.Add(item);
                        break;
                    }
                }
            }
        }
        else if (typeCommands == ComandsType.LargarItem)
        {
            foreach (var item in currentRoom.m_ItemsRoom)
            {
                if (item.m_NameItem == nomeItem)
                {
                    var jogadorComItem = player.Inventory.Where(i => i.m_NameItem == nomeItem).Select(s => s.m_NameItem == nomeItem).FirstOrDefault();
                    if(jogadorComItem)
                    {
                        if (item.m_Collectable)
                        {
                            retornoComando.Comando = "Item já foi largado.";
                            break;
                        }
                        else
                        {
                            retornoComando.Comando = "Deixou item " + nomeItem;
                            item.m_GetItem = false;
                            item.m_Collectable = true;
                            player.Inventory.Remove(item);
                            break;
                        }
                    }else{
                        retornoComando.Comando = "O jogador esta sem esse item.";
                        break;
                    }
                }
            }
        }

        return retornoComando;
    }
Esempio n. 42
0
    public void TellServerOurName(string stName, NetworkMessageInfo info)
    {
        string stWelcomeMsg = "Bem vindo ao servidor de MUD!\n";

        PlayerNode newEntry = new PlayerNode ();
        newEntry.stPlayerName = stName;
        newEntry.networkPlayer = info.sender;
        playerList.Add (newEntry);

        // TODO: adicionar verificacões, como login repetido, etc

        // Adiciona o novo jogador
        stWelcomeMsg += scriptRegras.AddNewPlayer (newEntry.networkPlayer, newEntry.stPlayerName);

        addGameChatMessage (newEntry.stPlayerName + " juntou-se ao servidor.");
        SendChatMessageTo (newEntry.networkPlayer, stWelcomeMsg);
    }
Esempio n. 43
0
    //Server function
    public void OnPlayerConnected(NetworkPlayer player)
    {
        Debug.Log("Entrou2");
        //Captura o Nome do personagem que conectou
        playerName = PlayerPrefs.GetString("playerName");
        var nameOfPlayer = playerName.Trim().ToLower().Replace(" ","");
        var existePlayerMesmoNome = playerList.Where(j => j.playerName == nameOfPlayer).Select(s => s.playerName == nameOfPlayer).FirstOrDefault();
        if(!existePlayerMesmoNome){
        PlayerNode newEntry = new PlayerNode();
        newEntry.playerName = nameOfPlayer;
        newEntry.networkPlayer = player;
        newEntry.Inventory = new List<Item>();
        //Adiciona a lista de player.
        playerList.Add(newEntry);
        //Cria as salas.
        if (!isRoomsCreate)
        {
            CreateRooms();
        }

        rooms[0].m_PlayerSalaRoom.Add(newEntry);

        networkView.RPC("SendMsgToClient", RPCMode.All, Network.player, "O jogador " + playerName + " acessou servidor!");
        networkView.RPC("SendMsgToClient", player, Network.player, IniciarMud());
        networkView.RPC("SendMsgToClient", player, Network.player, "Você está na sala " + rooms[0].m_NameRoom);

        }else{
            networkView.RPC("SendMsgToClient", player, Network.player, "Nome de personagem já existe.");
            Network.CloseConnection(player,true);
        }
        Debug.Log("Entrou3");
    }
	//Sent by newly connected clients, recieved by server
	void TellServerOurName(string name, NetworkMessageInfo info)
	{
		PlayerNode newEntry = new PlayerNode();
		newEntry.playerName = name;
		newEntry.networkPlayer = info.sender;
		playerList.Add(newEntry);

	}
Esempio n. 45
0
            private IEnumerable<IPlayerNode> GetChildrenWith2()
            {
                if (this.computedNodesWith2 == null)
                {
                    this.computedNodesWith2 = new List<IPlayerNode>();
                }
                else
                {
                    foreach (var node in this.computedNodesWith2)
                    {
                        yield return node;
                    }
                }

                if (!this.allNodesWith2Computed)
                {
                    IDictionary<LogarithmicGrid, IPlayerNode> knownPlayerNodesWithSumPlus2;
                    if (!this.SearchTree.knownPlayerNodesBySum.TryGetValue(this.Sum, out knownPlayerNodesWithSumPlus2))
                    {
                        knownPlayerNodesWithSumPlus2 = new Dictionary<LogarithmicGrid, IPlayerNode>();
                        this.SearchTree.knownPlayerNodesBySum.Add(this.Sum, knownPlayerNodesWithSumPlus2);
                    }

                    foreach (var possibleState in this.Grid.NextPossibleStatesWith2().Skip(this.computedNodesWith2.Count))
                    {
                        IPlayerNode playerNode;
                        if (!knownPlayerNodesWithSumPlus2.TryGetValue(possibleState, out playerNode))
                        {
                            playerNode = new PlayerNode(possibleState, this.SearchTree, this.Sum + 2);
                            knownPlayerNodesWithSumPlus2.Add(possibleState, playerNode);
                        }

                        this.computedNodesWith2.Add(playerNode);

                        yield return playerNode;
                    }
                }

                this.allNodesWith2Computed = true;
            }
Esempio n. 46
0
	void TellServerOurName(string name, NetworkMessageInfo info) {

		PlayerNode node = new PlayerNode();
		node.playerName = name;
		node.networkPlayer = info.sender;
		playerList.Add(node);

		addGameChatMessage(name+" joined the chat");
	}
Esempio n. 47
0
 // Server method
 void OnServerInitialized()
 {
     this.ShowChatWindow();
     // no support for sending an RPC on the server to the server itself :(
     PlayerNode newEntry = new PlayerNode();
     newEntry.PlayerName = this.playerName;
     newEntry.NetworkPlayer = Network.player;
     this.playerList.Add(newEntry);
     this.AddGameChatMessage(this.playerName + " joined the chat");
 }