Example #1
0
        public void CmdPlayerCombat(Transform attacker, Transform defender)
        {
            this.Attacker          = PlayerTable.Select((int)attacker.GetComponent <PlayerData>().netId.Value);
            this.AttackerCharacter = CharacterTable.Select(this.Attacker.CharacterID);
            this.AttackerInventory = InventoryTable.Select(this.Attacker.InventoryID);
            this.Weapon            = WeaponTable.Select(this.AttackerInventory.Weapon_ID);

            this.Defender = PlayerTable.Select((int)defender.GetComponent <PlayerData>().netId.Value);

            bool EnoughStamina;
            int  Damage = CountFireDamage(out EnoughStamina);

            if (EnoughStamina)
            {
                if (Damage > 0)
                {
                    LifeLoss(Damage);
                    this.Message = System.Convert.ToString(Damage);
                }
                else
                {
                    this.Message = "miss";
                }
            }
            else
            {
                this.Message = "influcient action points";
            }
        }
Example #2
0
        public void CmdCharacterSelection(string name, int ID)
        {
            Player    player = new Player();
            Character c      = CharacterTable.Select(ID);
            Inventory i      = new Inventory();
            Weapon    w      = WeaponTable.Select(c.Weapon);

            player.ID          = (int)netId.Value;
            player.Name        = name;
            player.Health      = Constants.player_basehealth + c.BHealth;
            player.Score       = 0;
            player.Armor       = 0;
            player.CharacterID = ID;
            player.InventoryID = InventoryTable.Select_Count() + 1;
            PlayerTable.Insert(player);

            i.Actual    = w.Ammo;
            i.Player_ID = player.ID;
            i.Weapon_ID = c.Weapon;
            i.Slot      = InventoryTable.Select_Count() + 1;
            InventoryTable.Insert(i);

            PlayerSelection.UsedWeapon = w.Name;

            Debug.Log("Srv exec." + name + "," + ID);

            _playerData.Name         = player.Name;
            _playerData.Armor        = player.Armor;
            _playerData.Health       = player.Health;
            _playerData.Score        = player.Score;
            _playerData.Inventory_ID = player.InventoryID;
            _playerData.Character_ID = player.CharacterID;
            _playerData.IsMoving     = false;
            // TODO: Generate position for player.
        }
Example #3
0
        static void createCharacter(string name, int stamina, int attack, int health, int weapon)
        {
            Character c = new Character();

            c.ID      = CharacterTable.Select_Count() + 1;
            c.Name    = name;
            c.Stamina = stamina;
            c.BAttack = attack;
            c.BHealth = health;
            c.Weapon  = weapon;
            CharacterTable.Insert(c);
        }
Example #4
0
        // Update is called once per frame
        void Update()
        {
            //Debug.Log("update");

            if (_playerData.Character_ID != 0 &&
                (_playerData.CharacterInstance == null || _oldCharId != _playerData.Character_ID))
            {
                _playerData.PlayerInstance    = PlayerTable.Select(_playerData.playerControllerId);
                _playerData.CharacterInstance = CharacterTable.Select(_playerData.Character_ID);
                _oldCharId = _playerData.Character_ID;
                Debug.Log("Refresh");
            }

            if (!isLocalPlayer)
            {
                return;
            }

            if (Input.GetMouseButtonDown(0) && !_playerData.IsMoving)
            {
                _playerData.MovePosition = Map.MAP.GetComponent <Map>()
                                           .GetGridPositionByBlock(Map
                                                                   .MAP.GetComponent <MapBlockBehaviour>()
                                                                   .SelectedBlock);
                GameObject moveBlock = Map.MAP.GetComponent <Map>().GetBlockOnPosition(_playerData.MovePosition);
                players = GameObject.FindGameObjectsWithTag("Player");
                bool shoot = false;
                foreach (GameObject p in players)
                {
                    Debug.Log(p.transform.position + " - " + moveBlock.transform.position);
                    if (Vector3.Distance(p.transform.position, moveBlock.transform.position) < 1f && p.name != _playerData.name)
                    {
                        _playerDataD = p.GetComponent <PlayerData>();
                        shoot        = true;
                        break;
                    }
                }

                if (!shoot)
                {
                    Debug.Log("if");
                    _playerData.IsMoving = true;
                }
                else
                {
                    Destroy(_playerDataD.gameObject);
                    Debug.Log("else");
                    PlayerBehaviour.RunCmdFire(_playerData.playerControllerId, _playerDataD.playerControllerId, _playerData.transform.position, _playerDataD.transform.position);
                }
            }

            float step = _playerData.Speed * Time.deltaTime;

            if (_playerData.IsMoving)
            {
                GameObject moveBlock = Map.MAP.GetComponent <Map>().GetBlockOnPosition(_playerData.MovePosition);
                float      distance  = Vector3.Distance(_playerData.transform.position, moveBlock.transform.position);


                if (distance > _playerData.CharacterInstance.Stamina * 10)
                {
                    this.message = "Too long";
                }
                else
                {
                    if (_playerData.GridPosition != _playerData.MovePosition)
                    {
                        //Debug.Log("moving");
                        transform.position =
                            Vector3.MoveTowards(transform.position, moveBlock.transform.position, step);
                        if (Vector3.Distance(transform.position, moveBlock.transform.position) < 0.1f)
                        {
                            _playerData.GridPosition = _playerData.MovePosition;
                        }
                    }
                    else
                    {
                        transform.position   = moveBlock.transform.position;
                        _playerData.IsMoving = false;
                    }
                }
            }
        }
Example #5
0
        public void CmdRefill(int id)
        {
            Player player = PlayerTable.Select(id);

            System.Random rnd  = new System.Random();
            int           rnum = rnd.Next(0, 100);

            if (rnum >= 0 && rnum <= 33) //healthpack
            {
                Character ch = CharacterTable.Select(player.CharacterID);
                player.Health = ch.BHealth + Constants.player_basehealth;
                PlayerTable.Update(player);
                this.message = "Health";
            }
            else if (rnum > 33 && rnum <= 66)//ammo
            {
                Inventory i = InventoryTable.Select(player.InventoryID);
                i.Actual = WeaponTable.Select(i.Weapon_ID).Ammo;
                InventoryTable.Update(i);
                this.message = "Ammo";
            }
            else //Weapon
            {
                Collection <Weapon>    weapons     = WeaponTable.Select();
                Collection <Inventory> inventories = InventoryTable.Select();
                Collection <Weapon>    notowned    = new Collection <Weapon>();
                foreach (Weapon w in weapons)
                {
                    bool add = true;
                    foreach (Inventory inv in inventories)
                    {
                        if (w.ID == inv.Weapon_ID && inv.Player_ID == player.ID) //pokud hráč již vlastní zbraň
                        {
                            add = false;
                            break;
                        }
                    }
                    if (add)
                    {
                        notowned.Add(w);
                    }
                }
                if (notowned.Count == 0) //pokud uz vlastnim vše
                {
                    Character ch = CharacterTable.Select(player.CharacterID);
                    player.Armor += 100;
                    PlayerTable.Update(player);
                    this.message = "Armor";
                }
                else
                {
                    int       WeaponID = rnd.Next(0, notowned.Count - 1);
                    Inventory i        = new Inventory();
                    i.Player_ID = player.ID;
                    i.Weapon_ID = notowned[WeaponID].ID;
                    i.Actual    = notowned[WeaponID].Ammo;
                    i.Slot      = InventoryTable.Select_Count() + 1;
                    InventoryTable.Insert(i);
                    this.message = notowned[WeaponID].Name;
                }
            }
            PlayerRefill.ObtainedItem = this.message;
        }
Example #6
0
        public static void Create(out string TestResult)
        {
            List <string> Comment = new List <string>();

            Comment.Add("Přidáno: \n");

            CharacterTable.DeleteAll();
            InventoryTable.DeleteAll();
            PlayerTable.DeleteAll();
            WeaponTable.DeleteAll();

            try
            {
                Comment.Add(Test_CreateWapon());
            }
            catch
            {
                Comment.Add("Zbraně se nevytvořily");
            }
            try
            {
                Comment.Add(Test_CreateCharacters());
            }
            catch
            {
                Comment.Add("Charactery se nevytvořily");
            }
            Comment.Add(" ====================================");
            Comment.Add("2 hráči");
            Comment.Add("=====================================");
            try
            {
                Comment.Add(Test_CreatePlayers());
            }
            catch
            {
                Comment.Add("Hráči se nevytvořili");
            }
            Comment.Add(" ====================================");
            Comment.Add("CombatSystem");
            Comment.Add("=====================================");
            try
            {
                Comment.Add(Test_PlayerCombat());
            }
            catch
            {
                Comment.Add("Nedošlo k souboji");
            }
            Comment.Add(" ====================================");
            Comment.Add("LootBox");
            Comment.Add("=====================================");
            try
            {
                for (uint i = 0; i < 100; i++)
                {
                    Comment.Add(Test_refill(1));
                }
            }
            catch
            {
                Comment.Add("Nepadlo nic");
            }

            try
            {
                /*Test_StatReport(1);
                *  Test_StatReport(2);*/
            }
            catch
            {
                Comment.Add("Nepovedlo se načíst z hráče");
            }



            var comment = System.String.Join("", Comment.ToArray());

            TestResult = comment;
            try
            {
                using (StreamWriter writer = new StreamWriter("QA_Tests.txt"))
                {
                    foreach (string s in Comment)
                    {
                        writer.WriteLine(s);
                    }
                }
            }
            catch { }
        }