protected void OnHit(GameObject other, WeaponSO staticData, Vector3 hitPoint)
    {
        Debug.Log(other.name);

        ICombat combat = other.GetComponentInChildren <ICombat>();

        if (combat != null)
        {
            Debug.Log("OnHit: " + other.name);

            combat.TakeDamage(staticData.damage, staticData.damageType);
        }
        else
        {
            Debug.Log("OnHit non-damageable:" + other.name);
        }

        if (staticData.hitGraphics != null)
        {
            GameObject hitGraphics = Instantiate(staticData.hitGraphics, hitPoint, Quaternion.Euler(0, 180, 0));
            Destroy(hitGraphics, 2f);
        }

        if (staticData.weaponDestructionGraphics != null)
        {
            GameObject graphics = Instantiate(staticData.weaponDestructionGraphics, hitPoint, Quaternion.identity);
            Destroy(graphics, 2f);
        }

        if (staticData.shouldWeaponDestructOnHit)
        {
            Destroy(gameObject);
        }
    }
Example #2
0
    public void DeSynch()
    {
        this.weaponSo = null;
        sr.sprite     = null;
        this.enabled  = false;

        player.DeSynch();
    }
Example #3
0
    public void SetWeapon(WeaponSO weapon)
    {
        damage     = weapon.damage;
        color      = weapon.color;
        attackType = weapon.attackType;
        weaponType = weapon.weaponType;

        EnableWeapon(weaponType);
    }
Example #4
0
        public static Weapon CreateWeapon(WeaponSO weaponSO)
        {
            var stats = new Dictionary <Type, Characteristic>()
            {
                { Type.Damage, new DamageCharacteristic(weaponSO.damage) }
            };

            return(new Weapon(weaponSO, stats));
        }
Example #5
0
    //MenuFuctions
    public void SetPlayersFromScriptable(int index_p1, int index_p2)
    {
        Player1_SO = PlayersList[index_p1];
        Player2_SO = PlayersList[index_p2];
        weapon1    = Player1_SO.weapon;
        weapon2    = Player2_SO.weapon;

        logText.text = "UI player select ok";
        Debug.Log("UI player select ok");
    }
 public void UnequipWeapon(WeaponSO item)
 {
     if (inventory.CanAddItem(item))
     {
         if (weaponPanel.RemoveItem(item))
         {
             item.Unequip(this, weaponPanel); // Remove Weapon item Stat
             inventory.AddItem(item);
         }
     }
 }
Example #7
0
 public bool CheckItemType(WeaponSO weaponSO)
 {
     for (int i = 0; i < weaponSlots.Length; i++)
     {
         if (weaponSlots[i].weaponType == weaponSO.equipmentType)
         {
             return(true);
         }
     }
     return(false);
 }
Example #8
0
    public void SetPlayersFromScriptable(PlayerSO player1, PlayerSO player2)
    {
        Player1_SO = player1;
        Player2_SO = player2;

        weapon1 = Player1_SO.weapon;
        weapon2 = Player2_SO.weapon;

        logText.text = "UI player select ok";
        Debug.Log("UI player select ok");
    }
Example #9
0
 public Weapon(WeaponSO item)
 {
     Name      = item.Name;
     Type      = item.Type;
     Value     = item.Value;
     Price     = item.Price;
     MaxInCell = item.MaxInCell;
     Rarity    = item.Rarity;
     DamageMax = item.DamageMax;
     DamageMin = item.DamageMin;
 }
Example #10
0
    public override bool CanReceiveItem(ItemSO item)
    {
        // baseSlot X
        // ItemSlot O
        if (item == null)
        {
            return(true);
        }
        WeaponSO weaponItem = item as WeaponSO;                               // item이 weaponItem이면 형변환을 수행, 아니면 null값 대입

        return(weaponItem != null && weaponItem.equipmentType == weaponType); // 만약 weaponItem이 있고 weaponType마저 알맞다면 bool값 리턴
    }
Example #11
0
 public void InitPlayer(string id, string name, Sprite playerFaceIcon, WeaponSO weapon, int health, Sprite profilePic)
 {
     this.id                 = id;
     this.name               = name;
     this.health             = health;
     this.PlayerFaceIcon     = playerFaceIcon;
     this.weapon             = weapon;
     this.aimController      = this.transform.GetComponentInChildren <AimController>();
     this.WeaponHodlingPoint = aimController.shotPoint;
     this.profilePic         = profilePic;
     this.animator           = GetComponent <Animator>();
 }
Example #12
0
    public void EquiptWeapon(WeaponSO weapon)
    {
        if (currentWeapon != null)
        {
            WeaponSO oldItem = currentWeapon;
            Inventory.instance.Add(oldItem);
        }

        currentWeapon = weapon;

        Callback();
    }
Example #13
0
 public bool RemoveItem(WeaponSO item)
 {
     for (int i = 0; i < weaponSlots.Length; i++)
     {
         if (weaponSlots[i].weaponType == item.type)
         {
             weaponSlots[i].Item   = null;
             weaponSlots[i].Amount = 0;
             return(true);
         }
     }
     return(false);
 }
Example #14
0
 public void UnEquip(WeaponSO item)
 {
     for (int i = 0; i < gunScript.Length; i++)
     {
         if (gunScript[i].weaponType == item.type)
         {
             if (gunScript != null)
             {
                 gunScript[i].sr.sprite = null;
                 gunScript[i].enabled   = false;
             }
         }
     }
 }
Example #15
0
    public bool AddItem(WeaponSO item, out WeaponSO previousItem)
    {
        for (int i = 0; i < weaponSlots.Length; i++)
        {
            if (weaponSlots[i].weaponType == item.type)
            {
                previousItem          = (WeaponSO)weaponSlots[i].Item;
                weaponSlots[i].Item   = item;
                weaponSlots[i].Amount = 1;
                return(true);
            }
        }

        previousItem = null;
        return(false);
    }
Example #16
0
        private void Start()
        {
            WeaponSO weaponData = GetComponent <GunController>().Weapon.WeaponData;

            shotSound   = weaponData.shotSound;
            noAmmoSound = weaponData.noAmmoSound;
            reloadSound = weaponData.reloadSound;

            amountOfPooledAudioSources = (int)(weaponData.shotsPerSecond * 2);

            for (int i = 0; i < amountOfPooledAudioSources; i++)
            {
                var audioSource = CreateNewAudioSource();
                audioSourcesPool.Enqueue(audioSource);
            }
        }
Example #17
0
    public void BuyWeapon(WeaponSO weapon)
    {
        if (player.healthPoints < weapon.price)
        {
            return;
        }

        player.availableWeapons.Add(weapon);
        player.healthPoints -= weapon.price;

        for (int i = 0; i < itemList.transform.childCount; i++)
        {
            if (itemList.transform.GetChild(i).GetComponent <StoreItem>().weapon.Equals(weapon))
            {
                Destroy(itemList.transform.GetChild(i).gameObject);
            }
        }
    }
    void SwapItem(BaseItemSlot _itemSlot)
    {
        //as = 만약 A = B as A라면 B를 A로 형변환하고, 아니면 null값을 준다
        WeaponSO dragWeaponItem = dragItemSlot.Item as WeaponSO;
        WeaponSO dropWeaponItem = _itemSlot.Item as WeaponSO;

        // dragWeapon = 처음 drag를 시작한 슬롯에 있던 아이템
        // dropWeapon = drag를 끝내고 drop할려는 슬롯에 있는 아이템

        if (_itemSlot is WeaponSlot) // 드롭한 곳이 무기슬롯일 때
        {
            if (dragWeaponItem != null)
            {
                dragWeaponItem.Equip(this, weaponPanel);
            }
            if (dropWeaponItem != null)
            {
                dropWeaponItem.Unequip(this, weaponPanel);
            }
        }
        if (dragItemSlot is WeaponSlot) // 드래그한 곳이 무기슬롯 일 때
        {
            if (dragWeaponItem != null)
            {
                dragWeaponItem.Unequip(this, weaponPanel);
            }
            if (dropWeaponItem != null)
            {
                dropWeaponItem.Equip(this, weaponPanel);
            }
        }

        // 인벤토리나 무기창 아무상관 없이 아이템을 swap & drop하게 해줌

        ItemSO draggedItem       = _itemSlot.Item;
        int    draggedItemAmount = dragItemSlot.Amount;

        _itemSlot.Item      = dragItemSlot.Item;
        dragItemSlot.Amount = _itemSlot.Amount;

        dragItemSlot.Item = draggedItem;
        _itemSlot.Amount  = draggedItemAmount;
    }
Example #19
0
    public void Equip(WeaponSO item)
    {
        for (int i = 0; i < gunScript.Length; i++)
        {
            if (gunScript[i].weaponType == item.type)
            {
                if (gunScript != null)
                {
                    gunScript[i].enabled = true;

                    //gunScript[i].maxAmmo = item.MaxAmmo;
                    gunScript[i].sr.sprite = item.Icon;

                    gunScript[i].RPM = item.RPM;

                    //gunScript[i].resetAmmo();
                }
            }
        }
    }
 public void EquipWeapon(WeaponSO item)
 {
     if (inventory.RemoveItem(item))
     {
         WeaponSO previousItem;
         if (weaponPanel.AddItem(item, out previousItem))
         {
             if (previousItem != null)
             {
                 inventory.AddItem(previousItem);
                 previousItem.Unequip(this, weaponPanel);
             }
             item.Equip(this, weaponPanel);
         }
         else
         {
             inventory.AddItem(item);
         }
     }
 }
Example #21
0
    public void Synch(WeaponSO item, Sprite sprite, GameObject bullet, GameObject EffMuz, EquipmentType wT, int m, float rpm, float mr, float aS, float Spr, float Mob, float Ergo, bool nR, bool aA, bool iB)
    {
        this.enabled       = true;
        this.weaponSo      = item;
        this.sr.sprite     = sprite;
        this.bulletToFire  = bullet;
        this.effectMuzzle  = EffMuz;
        this.EquipmentType = wT;
        this.Magazine      = m;
        this.RPM           = rpm;
        this.maxRange      = mr;
        this.aimingSec     = aS;
        this.Spread        = Spr;
        this.Mobility      = Mob;
        this.Ergonomic     = Ergo;
        this.noReload      = nR;
        this.autoAction    = aA;
        this.isBow         = iB;

        player.Synch();
    }
Example #22
0
    public void Remove(ItemSO item)
    {
        if (item is WeaponSO)
        {
            currentWeapon = null;
        }
        else if (item is EquiptmentSO)
        {
            if (item is HelmetSO)
            {
                currentEquiptment[0] = null;
            }
            else if (item is ArmorSO)
            {
                currentEquiptment[1] = null;
            }
            else if (item is BootsSO)
            {
                currentEquiptment[2] = null;
            }
        }

        Callback();
    }
Example #23
0
 private void EquiptWep(WeaponSO wep)
 {
     equipmentManager.EquiptWeapon(wep as WeaponSO);
 }
Example #24
0
 private void UpdateWeapon(WeaponSO newData)
 {
     currentWeapon.weaponData = newData;
     currentWeapon.GetComponent <SpriteRenderer>().sprite = newData.graphic;
 }
Example #25
0
    public GameObject InitializeCharacter(Vector3 initPosition, Quaternion initRotation, WeaponSO weapon, bool isAI = false)
    {
        GameObject PlayerObj = Instantiate(Prefab, initPosition, initRotation);

        if (isAI)
        {
            PlayerObj.layer = 12;  //Layer name for collisions PlayerAI = 12
        }
        else
        {
            PlayerObj.layer = 10; //Layer name for collisions Player
        }
        Player tmp = PlayerObj.AddComponent <Player>();

        tmp.InitPlayer(id, Name, PlayerFaceIcon, weapon, health, ProfilePic);

        return(PlayerObj);
    }
Example #26
0
 private Weapon(WeaponSO weaponSO, Dictionary <Type, Characteristic> stats) : base(weaponSO.name, stats)
 {
     WeaponData = weaponSO;
 }
Example #27
0
    public void EquiptWeapon(WeaponSO wep)
    {
        EquiptWep(wep);

        Remove(wep);
    }
        // Do we need to add a name tag?
        Image ItemIconDisplay(Transform Parent, Sprite image)
        {
            Image temp = new GameObject().AddComponent <Image>();

            temp.transform.SetParent(Parent, false);
            temp.sprite = image;
            if (!image)
            {
                temp.color = new Color()
                {
                    a = 0.0f
                }
            }
            ;
            return(temp);
        }

        ItemType DisplayItems = (ItemType)1;
        GameObject itemPanel {
            get; set;
        }
        GameObject CreateItemPanel()
        {
            GameObject MainPanel = Manager.GetPanel(MenuPanelParent.transform, new Vector2(1400, 300), new Vector2(0, 150));

            MainPanel.transform.SetSiblingIndex(1);
            VerticalLayoutGroup VLG = MainPanel.AddComponent <VerticalLayoutGroup>();

            MainPanel.name = "Item Window";
            VLG.padding    = new RectOffset()
            {
                bottom = 20, top = 20, left = 20, right = 20
            };
            VLG.childAlignment         = TextAnchor.UpperCenter;
            VLG.childControlHeight     = true; VLG.childControlWidth = true;
            VLG.childForceExpandHeight = false; VLG.childForceExpandWidth = true;

            Text titleGO = Manager.TextBox(MainPanel.transform, new Vector2(400, 50)).GetComponent <Text>();

            titleGO.alignment = TextAnchor.MiddleCenter;
            titleGO.text      = "Inventory";
            titleGO.fontSize  = 24;
            titleGO.name      = "Inventory Title TextBox";
            HorizontalLayoutGroup InventoryPanel = Manager.GetPanel(MainPanel.transform, new Vector2(400, 900), new Vector2(0, 150)).AddComponent <HorizontalLayoutGroup>();

            InventoryPanel.name = " Control Display Buttons";
            InventoryPanel.childControlHeight     = false;
            InventoryPanel.childForceExpandHeight = false;
            MainPanel.name = "Items Window";

            for (int i = 1; i < 7; i++)
            {
                int    test = i;
                Button Temp = Manager.UIButton(InventoryPanel.transform, ((ItemType)i).ToString());
                Temp.name = ((ItemType)i).ToString();
                Temp.onClick.AddListener(() => {
                    DisplayItems        = (ItemType)test;
                    itemsDisplayerPanel = ItemsDisplayPanel(MainPanel.transform, Inventory, DisplayItems);
                });
            }
            itemsDisplayerPanel = ItemsDisplayPanel(MainPanel.transform, Inventory, DisplayItems);

            return(MainPanel);
        }

        GameObject itemsDisplayerPanel {
            get; set;
        }
        GameObject ItemsDisplayPanel(Transform Parent, InventoryBase inventory, ItemType Type)
        {
            if (itemsDisplayerPanel)
            {
                Object.Destroy(itemsDisplayerPanel);
            }

            GridLayoutGroup Main = Manager.GetPanel(Parent, new Vector2(1400, 300), new Vector2(0, 150)).AddComponent <GridLayoutGroup>();

            Main.padding = new RectOffset()
            {
                bottom = 20, top = 20, left = 20, right = 20
            };
            Main.spacing = new Vector2(20, 20);
            for (int i = 0; i < inventory.ItemsInInventory.Count - 1; i++)
            {
                ItemSlot Slot    = inventory.ItemsInInventory[i];
                int      IndexOf = i;
                if (Slot.Item.Type == Type)
                {
                    Button temp = ItemButton(Main.transform, Slot);
                    temp.onClick.AddListener(() =>
                    {
                        GameObject pop = PopUpItemPanel(temp.GetComponent <RectTransform>().anchoredPosition
                                                        + new Vector2(575, -175)
                                                        , Slot, IndexOf);
                        // pop.AddComponent<PopUpMouseControl>();
                    });
                }
            }

            return(Main.gameObject);
        }

        Button ItemButton(Transform Parent, ItemSlot Slot)
        {
            Button temp = Manager.UIButton(Parent, Slot.Item.ItemName);

            temp.name = Slot.Item.ItemName;
            Text texttemp = temp.GetComponentInChildren <Text>();

            texttemp.alignment = TextAnchor.LowerCenter;
            if (Slot.Item.Stackable)
            {
                texttemp.text += Slot.Count;
            }
            temp.GetComponentInChildren <Text>().alignment = TextAnchor.LowerCenter;
            temp.GetComponent <Image>().sprite             = Slot.Item.Icon;


            return(temp);
        }

        GameObject PopUpItemPanel(Vector2 Pos, ItemSlot Slot, int IndexOf)
        {
            GameObject            PopUp = Manager.GetPanel(Manager.UICanvas().transform, new Vector2(300, 300), Pos);
            HorizontalLayoutGroup group = PopUp.AddComponent <HorizontalLayoutGroup>();

            PopUp.AddComponent <PopUpMouseControl>();

            group.childControlWidth = false;

            Text info = Manager.TextBox(PopUp.transform, new Vector2(150, 300));

            info.text  = Slot.Item.ItemName + "\n";
            info.text += Slot.Item.Description;

            VerticalLayoutGroup ButtonPanel = Manager.GetPanel(PopUp.transform, new Vector2(150, 300), Pos).AddComponent <VerticalLayoutGroup>();

            switch (Slot.Item.Type)
            {
            case ItemType.General:
                Button use = Manager.UIButton(ButtonPanel.transform, "Use Item");
                use.onClick.AddListener(() =>
                {
                    RecoveryItemSO temp = (RecoveryItemSO)Slot.Item;
                    temp.Use(Inventory, IndexOf, Character);

                    itemsDisplayerPanel = ItemsDisplayPanel(itemPanel.transform, Inventory, DisplayItems);
                    Object.Destroy(PopUp);
                });
                info.text += "\nQuantity: " + Slot.Count;
                break;

            case ItemType.Armor:
            case ItemType.Weapon:
                Button Equip = Manager.UIButton(ButtonPanel.transform, "Equip");
                Equip.onClick.AddListener(() =>
                {
                    switch (Slot.Item.Type)
                    {
                    case ItemType.Armor:
                        ArmorSO Armor = (ArmorSO)Slot.Item;
                        Armor.EquipItem(Inventory, Equipment, IndexOf, Character);
                        break;

                    case ItemType.Weapon:
                        WeaponSO weapon = (WeaponSO)Slot.Item;
                        weapon.EquipItem(Inventory, Equipment, IndexOf, Character);

                        break;
                    }
                    itemsDisplayerPanel = ItemsDisplayPanel(itemPanel.transform, Inventory, DisplayItems);
                    playerStats         = CreatePlayerPanel();
                    Object.Destroy(PopUp);
                });
                Button Mod = Manager.UIButton(ButtonPanel.transform, "Modify");
                Mod.onClick.AddListener(() => Debug.LogWarning("Implentation to be added once Skill/Magic system designed"));
                Button Dismantle = Manager.UIButton(ButtonPanel.transform, "Dismantle");

                break;

            case ItemType.Quest:
                Button View = Manager.UIButton(ButtonPanel.transform, "View Item");

                break;

            case ItemType.Blueprint_Recipes:
                break;
            }
            if (Slot.Item.Type != ItemType.Quest)
            {
                Button Drop = Manager.UIButton(ButtonPanel.transform, "Drop");
                Drop.onClick.AddListener(() => {
                    Slot.Item.RemoveFromInventory(Inventory, IndexOf);
                    Object.Destroy(PopUp);
                });
            }
            // Button Cancel = Manager.UIButton(ButtonPanel.transform, "Cancel");

            return(PopUp);
        }
    }
Example #29
0
 public void SetWeapon(WeaponSO newWeapon)
 {
     weaponSO     = newWeapon;
     WeaponSprite = weaponSO.sprite;
     GetComponent <SpriteRenderer>().sprite = WeaponSprite;
 }
 protected void OnHit(Collider other, WeaponSO staticData, Vector3 hitPoint)
 {
     OnHit(other.gameObject, staticData, hitPoint);
 }