Ejemplo n.º 1
0
 public override void Logic()
 {
     CreaturesContainer.MovingLogic();
     AttacksContainer.Logic();
     NetContainer.Logic();
     mainWorld.Logic(curPlayer);
 }
Ejemplo n.º 2
0
        public Creature(char s, Vector pos, RLColor c)
        {
            this.symbol   = s;
            this.position = pos;
            this.color    = c;

            this.Init();

            CreaturesContainer.Add(this);
        }
Ejemplo n.º 3
0
 public virtual void GetDamaged(Attack att)
 {
     this.Hp -= att.damage;
     if (this.Hp.GetCurrent() <= 0)
     {
         this.isChanged    = true;
         this.changedInfo += "dead;";
         CreaturesContainer.Remove(this);
     }
 }
Ejemplo n.º 4
0
 private void Server_lostConnection(string id)
 {
     foreach (var player in connectedPlayers)
     {
         if (player.playerId == id)
         {
             connectedPlayers.Remove(player);
             CreaturesContainer.Remove(player);
         }
     }
 }
Ejemplo n.º 5
0
        public override void Render(RLConsole mainConsole)
        {
            RLConsole.Blit(statsConsole, 0, 0, statsConsoleRect.Size.X, statsConsoleRect.Size.Y,
                           mainConsole, statsConsoleRect.Pos.X, statsConsoleRect.Pos.Y);
            RLConsole.Blit(worldConsole, 0, 0, worldConsoleRect.Size.X, worldConsoleRect.Size.Y,
                           mainConsole, worldConsoleRect.Pos.X, worldConsoleRect.Pos.Y);

            mainWorld.Render(worldConsole);
            CreaturesContainer.RenderLogic(worldConsole);
            AttacksContainer.Render(worldConsole);
            mainHud.Render(statsConsole);
        }
Ejemplo n.º 6
0
        public override void TryToMove(Vector dir)
        {
            base.TryToMove(dir);

            if (this.prevPos == this.position)
            {
                var crea = CreaturesContainer.GetCreatureOnPosition(this.position + dir);
                if (crea != null)
                {
                }
            }
        }
Ejemplo n.º 7
0
 public void Logic()
 {
     switch (type)
     {
     case AttackType.Melee:
     {
         for (int i = 0; i < realPos.Count; i++)
         {
             var crea = CreaturesContainer.GetCreatureOnPosition(realPos[i]);
             if (crea != null && crea != parent && !this.damagedCreatures.Contains(crea))
             {
                 crea.GetDamaged(this);
                 this.damagedCreatures.Add(crea);
             }
         }
         break;
     }
     }
 }
Ejemplo n.º 8
0
        private void Client_DataReceived(byte[] Data, string ID)
        {
            string responce = Network.ConvertBytesToString(Data);

            Console.WriteLine(responce + " is recieved!");
            if (responce.Contains("gac"))
            {
                responce = responce.Replace("gac \n", "");
                var list = responce.Split('\n');

                foreach (var item in list)
                {
                    if (item == "")
                    {
                        continue;
                    }
                    string itemCopy = item;
                    bool   isMe     = false;
                    if (itemCopy[0] == 'p')
                    {
                        isMe     = true;
                        itemCopy = itemCopy.Remove(0, 1);
                    }
                    int Id = Convert.ToInt32(Network.MiniParce(ref itemCopy, ':'));
                    int x  = Convert.ToInt32(Network.MiniParce(ref itemCopy, ','));
                    int y  = Convert.ToInt32(Network.MiniParce(ref itemCopy, ','));
                    itemCopy = itemCopy.Remove(0, 1);
                    char sym = itemCopy[0];//Convert.ToChar(itemCopy);

                    if (isMe)
                    {
                        var player = new Player(sym, new Vector(x, y), RLColor.White);
                        player.ID = Id;
                    }
                    else
                    {
                        var crea = new Creature(sym, new Vector(x, y), RLColor.White);
                        crea.ID = Id;
                    }
                }
            }
            else if (responce.Contains("dead"))
            {
                string copy = responce;
                int    Id   = Convert.ToInt32(Network.MiniParce(ref copy, ':'));

                var crea = CreaturesContainer.GetCreature(Id);
                if (crea != null)
                {
                    CreaturesContainer.Remove(crea);
                    crea = null;
                }
            }
            else
            {
                string copy = responce;
                int    Id   = Convert.ToInt32(Network.MiniParce(ref copy, ':'));
                int    x    = Convert.ToInt32(Network.MiniParce(ref copy, ','));
                int    y    = Convert.ToInt32(Network.MiniParce(ref copy, ';'));

                var crea = CreaturesContainer.GetCreature(Id);
                if (crea != null)
                {
                    crea.UpdateData(new Vector(x, y));
                }
            }
        }