示例#1
0
        private void OnServerReceiveTeleportMsg(IServerPlayer fromPlayer, TeleportMsg msg)
        {
            if (!msg.DoRemove)
            {
                if (Teleports.ContainsKey(msg.Pos))
                {
                    Teleports[msg.Pos] = msg.Data;
                }
                else
                {
                    Teleports.Add(msg.Pos, msg.Data);
                }
            }
            else
            {
                if (Teleports.ContainsKey(msg.Pos))
                {
                    Teleports.Remove(msg.Pos);
                }
            }

            if (!msg.Synced)
            {
                serverChannel.BroadcastPacket(new TeleportMsg(
                                                  msg.Pos,
                                                  msg.Data,
                                                  msg.DoRemove,
                                                  true
                                                  ));
            }
        }
示例#2
0
 protected void AddTeleport()
 {
     if (this[Cursor.Position.X, Cursor.Position.Y] is Blank)
     {
         foreach (var t in Teleports)
         {
             if (!t.IsTeleport())
             {
                 t.AddExitPoint(Cursor.Position);
                 Add(t);
                 return;
             }
         }
         var tel = new Teleport(Cursor.Position);
         Teleports.Add(tel);
         Add(tel);
     }
 }
示例#3
0
    public void SetupTeleport()
    {
        List <Transform> allTeleportHoles = new List <Transform>();

        for (int i = 0; i < _levelHoles.Count; i++)
        {
            foreach (Transform t in _levelHoles[i])
            {
                if (t.name.EndsWith("T"))
                {
                    allTeleportHoles.Add(t);
                }
            }
        }

        Teleports.Clear();
        Teleports.Add(allTeleportHoles[Random.Range(0, allTeleportHoles.Count)]);
        allTeleportHoles.Remove(Teleports[0]);
        Teleports.Add(allTeleportHoles[Random.Range(0, allTeleportHoles.Count)]);
    }
示例#4
0
        public Node(int x, int y, NodeType type, char symbol)
        {
            Position = new Coordinate(x, y);
            Type     = type;
            Symbol   = symbol;
            List <Coordinate> sides = GetSides(x, y);

            if (type == NodeType.PATH)
            {
                Field.Add(Position, this);

                foreach (var side in sides)
                {
                    if (Field.ContainsKey(side))
                    {
                        AddEdge(Field[side]);
                    }
                }
            }
            else
            {
                Teleports.Add(Position, this);

                foreach (var side in sides)
                {
                    if (Teleports.ContainsKey(side))
                    {
                        Node teleport = Teleports[side];
                        if (symbol == 'A' && teleport.Symbol == 'A')
                        {
                            Type              = NodeType.START;
                            teleport.Type     = NodeType.START;
                            Soulmate          = teleport;
                            teleport.Soulmate = this;
                        }
                        else if (symbol == 'Z' && teleport.Symbol == 'Z')
                        {
                            Type              = NodeType.END;
                            teleport.Type     = NodeType.END;
                            Soulmate          = teleport;
                            teleport.Soulmate = this;
                        }
                        else
                        {
                            string telId = string.Concat(new[] { symbol, teleport.Symbol });

                            var pair = new List <Node> {
                                this, teleport
                            };
                            if (TeleportIDs.ContainsKey(telId))
                            {
                                TeleportIDs[telId].AddRange(pair);
                            }
                            else
                            {
                                TeleportIDs.Add(telId, pair);
                            }
                        }
                    }
                }
            }
        }