예제 #1
0
    public void OpenBox(int rng, int dmg, int resPerHit, int id, Sprite sprt)
    {
        if (!wepChange)
        {
            if (hatSwitch)
            {
                wepChange = hatSwitch.gameObject.GetComponent <WeaponChange>();
            }
            else
            {
                wepChange = FindObjectOfType <WeaponChange>();
            }
        }

        weaponChangeBox.gameObject.SetActive(true);
        wepImg.sprite        = sprt;
        wepImgDmg.text       = "Damage per hit: " + dmg.ToString();
        wepImgResPerHit.text = "Resources per hit: " + resPerHit.ToString();

        #region Changing color of test based on damage
        if (wepChange.weaponObjectsInInventory[0] != null)
        {
            if ((dmg > wepChange.weaponDamageInInventory[0]))
            {
                wepImgDmg.color = Color.green;
            }
            else if (dmg < wepChange.weaponDamageInInventory[0])
            {
                wepImgDmg.color = Color.red;
            }
            else
            {
                wepImgDmg.color = Color.white;
            }

            if (resPerHit > wepChange.weaponObjectsInInventory[0].GetComponent <ResourceGatheringScript>().resourceGain)
            {
                wepImgResPerHit.color = Color.green;
            }
            else if (resPerHit < wepChange.weaponObjectsInInventory[0].GetComponent <ResourceGatheringScript>().resourceGain)
            {
                wepImgResPerHit.color = Color.red;
            }
            else
            {
                wepImgResPerHit.color = Color.white;
            }
        }
        else
        {
            wepImgDmg.color       = Color.green;
            wepImgResPerHit.color = Color.green;
        }
        #endregion

        slot.text = "Take weapon on slot " + id + " ?";
        _rng      = rng;
        _id       = id;
        _dmg      = dmg;
    }
예제 #2
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
     if (!plr && FindObjectOfType <Player>())
     {
         plr = FindObjectOfType <Player>().gameObject.GetComponent <Transform>();
     }
     if (!handPos)
     {
         handPos = plr.Find("HandPos");
     }
     if (!currentWeaponObject && plr.GetComponentInChildren <Weapon>() != null)
     {
         currentWeaponObject         = plr.GetComponentInChildren <Weapon>().transform;
         currentWeaponId             = 1;
         currentWeapon               = currentWeaponObject.name;
         weaponObjectsInInventory[0] = currentWeaponObject;
         weaponImgs[0].sprite        = currentWeaponObject.GetComponentInChildren <SpriteRenderer>().sprite;
         weaponImgs[0].color         = new Color(weaponImgs[0].color.r, weaponImgs[0].color.g, weaponImgs[0].color.b, 1f);
     }
     hud = PlrHUD.Instance;
 }
예제 #3
0
    public void RngWeaponChange()
    {
        if (!wepChange)
        {
            wepChange = FindObjectOfType <WeaponChange>();
        }

        if (wepChange.weaponList[_rng].GetComponent <Ability>())
        {
            Ability ab = wepChange.weaponList[_rng].GetComponent <Ability>();

            skillImg.gameObject.SetActive(true);
            skillImg.sprite = ab.SkillImg;
            skillName.text  = ab.SkillName;
            skillDesc.text  = ab.SkillDesc;
        }
        else
        {
            skillImg.gameObject.SetActive(false);
            skillName.text = "";
            skillDesc.text = "";
        }

        ChangeSkillCooldown(0, 1);
        wepChange.WeaponChangeInven(wepChange.weaponList[_rng], _id, _dmg);
        wepChange.curWeaponNumInList = _rng;
        weaponChangeBox.gameObject.SetActive(false);

        if (wavSpawner.curBox)
        {
            wavSpawner.curBox.gameObject.SetActive(false);
        }
    }
예제 #4
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
        public void WeaponChangeCanBeInitializedWithNullDuration()
        {
            var weapon = Substitute.For <IWeapon>();

            WeaponChange powerup = new WeaponChange(weapon, null);

            Assert.AreEqual(null, powerup.Duration());
        }
        public void WeaponChangeCanBeInitializedWithCustomDuration()
        {
            var weapon = Substitute.For <IWeapon>();

            WeaponChange powerup = new WeaponChange(weapon, 25f);

            Assert.AreEqual(25f, powerup.Duration());
        }
예제 #7
0
 private void Awake()
 {
     weaponChange = GameObject.FindObjectOfType <WeaponChange>();
     inventory    = GameObject.FindObjectOfType <Inventory>();
     database     = GameObject.FindObjectOfType <ItemDatabase>();
     pauseMenu    = GameObject.FindObjectOfType <PauseMenu>();
     toolBelt     = GameObject.FindObjectOfType <ToolBelt>();
     //RemoveAllItems();
 }
        public void WeaponChangePowerupIdentifier()
        {
            var player = Substitute.For <IArmable>();
            var weapon = Substitute.For <IWeapon>();

            WeaponChange powerup = new WeaponChange(weapon);

            Assert.AreEqual(Powerups.Tripleshot, powerup.Identifier());
        }
예제 #9
0
 // Use this for initialization
 void Start()
 {
     Movement.SetActive(false);
     Turret.SetActive(false);
     MeleeAtack.SetActive(false);
     Barricade.SetActive(false);
     Shoot.SetActive(false);
     WeaponChange.SetActive(false);
 }
        public void RemovesWeaponChangeFromWeapon()
        {
            var player = Substitute.For <IArmable>();

            WeaponChange powerup = new WeaponChange(Substitute.For <IWeapon>());

            powerup.Remove(player);

            player.Received().DefaultWeapon();
        }
예제 #11
0
 void Start()
 {
     if (!wepChange)
     {
         wepChange = WeaponChange.Instance;
     }
     if (!plrHud)
     {
         plrHud = PlrHUD.Instance;
     }
 }
        public void AppliesWeaponChangeToPlayer()
        {
            var player = Substitute.For <IArmable>();
            var weapon = Substitute.For <IWeapon>();

            WeaponChange powerup = new WeaponChange(weapon);

            powerup.Apply(player);

            player.Received().ChangeWeapon(weapon);
        }
예제 #13
0
    // Use this for initialization
    void Start()
    {
        if (gameObject.tag != "localPlayer")
        {
            return;
        }

        cam = GameObject.FindWithTag("localCamera");

        ObjetPris    = false;
        weaponChange = gameObject.GetComponent <WeaponChange>();
        netSpawner   = gameObject.GetComponent <NetworkSpawner>();
    }
예제 #14
0
 // Use this for initialization
 void Start()
 {
     playerCamera     = gameObject.GetComponent <Camera>();
     player           = gameObject.transform.root.gameObject;
     playerShooting   = player.GetComponent <PlayerShooting>();
     mouseLookX       = player.GetComponent <MouseLook>();
     mouseLookY       = playerCamera.GetComponent <MouseLook>();
     playerGUI        = playerCamera.GetComponent <PlayerGUI>();
     defaultSniperFOV = playerCamera.fieldOfView;
     weaponChange     = player.GetComponent <WeaponChange>();
     gun        = GameObject.FindGameObjectWithTag("Gun");
     weaponData = gun.GetComponentInChildren <WeaponData>();
 }
예제 #15
0
    // Start is called before the first frame update
    void Start()
    {
        playerManager          = FindObjectOfType <PlayerManager>();
        hungerThirst           = FindObjectOfType <HungerThirst>();
        weaponChange           = FindObjectOfType <WeaponChange>();
        database               = FindObjectOfType <ItemDatabase>();
        inventory              = FindObjectOfType <Inventory>();
        usingSounds            = FindObjectOfType <UsingSounds>();
        groundPlacementManager = FindObjectOfType <GroundPlacementManager>();

        selectorImage         = toolBeltSlots[selectedItem].transform.GetChild(2).GetComponent <Image>();
        selectorImage.enabled = true;
    }
예제 #16
0
        private void Update()
        {
            var horizontal = Input.GetAxis("Horizontal");

            if (!Mathf.Approximately(horizontal, 0f))
            {
                //Debug.Log("Horizontal " + horizontal);
                HorizontalAxis.SafeInvoke(horizontal);
            }

            var vertical = Input.GetAxis("Vertical");

            if (!Mathf.Approximately(vertical, 0f))
            {
                //Debug.Log("Vertical " + vertical);
                VerticalAxis.SafeInvoke(vertical);
            }

            var fire = Input.GetAxis("Fire1");

            if (!Mathf.Approximately(fire, 0f) && !_firePress)
            {
                _firePress = true;
                Fire.SafeInvoke();
            }

            if (Mathf.Approximately(fire, 0f))
            {
                _firePress = false;
            }

            var weapon = Input.GetAxis("WeaponChange");

            if (!Mathf.Approximately(weapon, 0f) && !_weaponPress)
            {
                _weaponPress = true;
                WeaponChange.SafeInvoke(weapon);
            }

            if (Mathf.Approximately(weapon, 0f))
            {
                _weaponPress = false;
            }

            if (Input.GetKeyDown(KeyCode.X))
            {
                Fire.SafeInvoke();
            }
        }
 void Start()
 {
     fxManager                 = GameObject.FindObjectOfType <FXManager>();
     weaponChange              = gameObject.GetComponent <WeaponChange>();
     gun                       = GameObject.FindGameObjectWithTag("Gun");
     weaponData                = gun.GetComponentInChildren <WeaponData>();
     fontSize                  = new GUIStyle();
     fontSize.fontSize         = 40;
     fontSize.normal.textColor = Color.white;
     if (fxManager == null)
     {
         Debug.Log("couldn't find FxManager");
     }
     if (weaponData == null)
     {
         Debug.Log("couldn't find Weapon Data");
     }
 }
예제 #18
0
    private void Start()
    {
        skillNormCol = skillCooldownImg.color;

        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        if (!plr && FindObjectOfType <Player>())
        {
            plr = FindObjectOfType <Player>();
        }
        if (!wepChange)
        {
            wepChange = WeaponChange.Instance;
        }
        if (!hatSwitch && FindObjectOfType <HatSwitch>())
        {
            hatSwitch = FindObjectOfType <HatSwitch>();
        }
        if (!wavSpawner)
        {
            wavSpawner = hatSwitch.gameObject.GetComponent <WaveSpawner>();
        }

        if (hat != null)
        {
            if (hatSwitch)
            {
                hatSwitch.ChangeHat(hat.sprt, hat.dashLength, hat.dashRegen, hat.dashDmg, hat.spd);
            }
        }

        skillInfoImg.gameObject.SetActive(false);
        skillName.text = "";
        skillDesc.text = "";

        cam = Camera.main;
    }
예제 #19
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (!wepChange)
        {
            wepChange = WeaponChange.Instance;
        }
        if (!plrHud)
        {
            plrHud = PlrHUD.Instance;
        }

        if (collision.collider.CompareTag("Player") && wepChange)
        {
            int rng;
            if (wepChange.currentWeaponObject == null)
            {
                rng = Random.Range(0, 4);
            }
            else
            {
                rng = Random.Range(Mathf.Abs(wepChange.curWeaponNumInList - 1), wepChange.curWeaponNumInList + 3);
            }

            if (rng >= wepChange.weaponList.Length)
            {
                rng = wepChange.weaponList.Length - 1;
            }

            if (wepChange.weaponList[rng].GetComponent <Boomerang>() || wepChange.weaponList[rng].GetComponent <BowHandler>())
            {
                plrHud.OpenBox(rng, BowOrBoom(wepChange.weaponList[rng]), "N\\A", 1, wepChange.weaponList[rng].GetComponent <SpriteRenderer>().sprite);
            }
            else
            {
                plrHud.OpenBox(rng, Random.Range(wepChange.weaponList[rng].GetComponent <Weapon>().dmg / 3, wepChange.weaponList[rng].GetComponent <Weapon>().dmg * 2), wepChange.weaponList[rng].GetComponent <ResourceGatheringScript>().resourceGain, 0, wepChange.weaponList[rng].Find("Sprite").GetComponent <SpriteRenderer>().sprite);
            }
        }
        else
        {
            wepChange = FindObjectOfType <WeaponChange>();
            plrHud    = FindObjectOfType <PlrHUD>();
        }
    }
예제 #20
0
        public void ChangeWeapon(WeaponChange weaponChange)
        {
            _currentWeapon.Deactivate();

            if (_weaponIndex == _weapons.Count - 1 && weaponChange == WeaponChange.Next)
            {
                _weaponIndex = 0;
            }
            else if (_weaponIndex == 0 && weaponChange == WeaponChange.Previous)
            {
                _weaponIndex = _weapons.Count - 1;
            }
            else
            {
                _weaponIndex += (int)weaponChange;
            }

            _currentWeapon = _weapons[_weaponIndex];
            _currentWeapon.Activate();
        }
예제 #21
0
    // Use this for initialization
    void Start()
    {
        if (gameObject.tag != "localPlayer")
        {
            return;
        }
        PVMax = 100;
        PV    = PVMax;
        Mort  = false;

        bloodImage         = BloodScreen.GetComponent <Image>();
        BloodScreenOpacity = 0f;
        couleurBloodScreen = new Color(1f, 1f, 1f, 0f);

        attaque      = Couteau.GetComponent <Attaque>();
        furryScript  = Couteau.GetComponent <Furry>();
        baguette     = Couteau.GetComponent <Baguette>();
        weaponchange = gameObject.GetComponent <WeaponChange>();

        fpsCam = GameObject.FindWithTag("localCamera").GetComponent <Camera>();
    }
예제 #22
0
    //장비 해제
    public void ItemClick(PointerEventData evt)
    {
        WeaponChange _weaponChange = Managers.Game.GetPlayer().GetComponent <WeaponChange>();
        int          removeItemID  = Managers.Equip.wearItems[(int)slotName];


        if (removeItemID == 0)
        {
            return;
        }

        if (slotName == UI_Equipment.GameObjects.UI_Weapon_Slot)
        {
            _weaponChange.OnWeaponRemoveEquip();
        }

        //인벤토리에 추가
        if (!Managers.Inven.Add(removeItemID, Define.InvenType.Equipments))
        {
            return;
        }

        //장비창의 정보를 삭제 시켜주고 아이템 스탯도 다시 계산해 줌.
        Managers.Sound.Play("Sounds/GameSound/EquipItem");
        Managers.Equip.wearItems[(int)slotName] = 0;
        Managers.Equip.WearingItemsSumStats();


        //아이콘 삭제.
        Transform equipItemIcon = gameObject.transform.GetChild(0);

        if (equipItemIcon.GetComponent <Image>().sprite == null)
        {
            return;
        }
        equipItemIcon.GetComponent <Image>().sprite  = null;
        equipItemIcon.GetComponent <Image>().enabled = false;
    }
예제 #23
0
    private void Awake()
    {
        turnedOff = false;
        instance  = this;

        if (!hud)
        {
            hud = FindObjectOfType <PlrHUD>();
        }
        if (!wepChange)
        {
            wepChange = GetComponent <WeaponChange>();
        }
        if (!mainCam)
        {
            mainCam = Camera.main;
        }
        if (!camFoll)
        {
            camFoll = FindObjectOfType <CameraFollow>();
        }
        if (!hatSwitch)
        {
            hatSwitch = GetComponent <HatSwitch>();
        }
        if (!wavSpawner)
        {
            wavSpawner = GetComponent <WaveSpawner>();
        }

        //#if UNITY_EDITOR
        //        isTesting = true;
        //#else
        //        isTesting = false;
        //#endif
    }
예제 #24
0
 void Start()
 {
     weponchange = GameObject.Find("Canvas").GetComponent<WeaponChange>();
 }
 // Use this for initialization
 void Start()
 {
     weaponChange = gameObject.GetComponent <WeaponChange>();
 }