/// <summary>
    /// Equip weapon method used to pickup starting weapon
    /// and inside an equip method for picking up new weapons during gameplay
    /// </summary>
    /// <param name="weapon">Weapon to equip</param>
    private void Equip(WeaponConfiguration weapon)
    {
        if (weapon == null)
        {
            return;
        }

        if (CurrentWeapon == null)
        {
            var obj = Instantiate(weapon.weaponPrefab.gameObject, Controller.instance.WeaponPosition, false);

            obj.name      = weapon.weaponPrefab.name;
            CurrentWeapon = obj.GetComponent <Weapon>();
            CurrentWeapon.PickedUp(this);
            CurrentWeapon.Selected();
            Helpers.RecursiveLayerChange(obj.transform, LayerMask.NameToLayer("Weapon"));
        }
        else
        {
            if (CurrentWeapon.weaponConfiguration == weapon)
            {
                // TODO : Fill the clip of this weapon
            }
            else
            {
                Instantiate(CurrentWeapon, Controller.instance.WeaponPosition, false);
                CurrentWeapon.Selected();
            }
        }
        Controller.instance.AudioSource.PlayOneShot(EquipClip);
    }
    public void SetWeaponConfiguration(WeaponId weapon, WeaponConfiguration weaponConfiguration, WeaponSkillLevel skill = WeaponSkillLevel.Poor)
    {
        this.weaponConfigurations[weapon][skill] = weaponConfiguration;
        var packet = CreateSetStatPacket(weapon, weaponConfiguration, skill);

        this.server.BroadcastPacket(packet);
    }
    /// <summary>
    /// Check if the player can afford an upgrade to the next level
    /// if the preview item is a weapon
    /// </summary>
    private void OnGoldChanged()
    {
        if (previewItem.itemType == ItemType.Weapon)
        {
            WeaponConfiguration weapon = previewItem as WeaponConfiguration;

            if (weapon.levels.Length == 0 || weapon.isAtMaxLevel)
            {
                return;
            }

            if (GameManager.instance.Gold.CanAfford(weapon.levels[weapon.currentLevel].cost))
            {
                UpgradeButton.interactable = false;
            }
            else
            {
                UpgradeButton.interactable = true;
            }
        }
        else
        {
            if (PurchaseButton.gameObject.activeSelf)
            {
                PurchaseButton.interactable = GameManager.instance.Gold.CanAfford((int)previewItem.itemCost);
            }
        }
    }
Example #4
0
    private void AssignEntry(int index, int entry)
    {
        hotbarEntries[index].HotbarEntry = entry;
        WeaponConfiguration currentWeapon = Character.CurrentWeapon.weaponConfiguration;

        if (index == 1)
        {
            if (currentWeapon == Character.StartingWeapons[entry])
            {
                HotImg1.color = new Color32(255, 255, 0, 190);
                HotImg2.color = new Color32(0, 0, 0, 152);
                HotImg3.color = new Color32(0, 0, 0, 152);
            }
        }
        else if (index == 2)
        {
            if (currentWeapon == Character.StartingWeapons[entry])
            {
                HotImg1.color = new Color32(0, 0, 0, 152);
                HotImg2.color = new Color32(255, 255, 0, 190);
                HotImg3.color = new Color32(0, 0, 0, 152);
            }
        }
        else if (index == 3)
        {
            if (currentWeapon == Character.StartingWeapons[entry])
            {
                HotImg1.color = new Color32(0, 0, 0, 152);
                HotImg2.color = new Color32(0, 0, 0, 152);
                HotImg3.color = new Color32(255, 255, 0, 190);
            }
        }
        hotbarEntries[index].InitializeWeaponEntry();
    }
Example #5
0
 private void Start()
 {
     damage      = 0;
     fireRate    = 0;
     clipSize    = 0;
     isAnimating = true;
     weapon      = item as WeaponConfiguration;
 }
Example #6
0
    public void ShowOtherWeaponsTwo()
    {
        if (GameManager.instance == null)
        {
            return;
        }

        if (SelectionButtonPrefab == null || Layout == null || m_PurchasedWeaponList == null)
        {
            return;
        }

        ClearLayout();
        m_Buttons = new List <Button>();

        int count = WeaponList.Count;

        for (int i = 0; i < m_PurchasedWeaponList.Count; i++)
        {
            for (int j = 0; j < count; j++)
            {
                if (m_PurchasedWeaponList[i].id == WeaponList[j].id)
                {
                    WeaponConfiguration weapon = WeaponList[j].Item as WeaponConfiguration;
                    if (weapon != null && (weapon.Ammo.Type != Ammo.AmmoType.PISTOL &&
                                           weapon.Ammo.Type != Ammo.AmmoType.RIFLE))
                    {
                        SelectWeaponButton button = CreateWeaponButtonTwo(weapon);
                        button.transform.SetParent(Layout.transform);
                        button.transform.localScale = Vector3.one;
                        if (!m_Buttons.Contains(button.GetComponent <Button>()))
                        {
                            m_Buttons.Add(button.GetComponent <Button>());
                        }
                    }
                }
            }
        }

        if (m_Buttons.Count == 0)
        {
            return;
        }

        if (RightBuffer != null)
        {
            RightBuffer.SetAsLastSibling();
        }

        for (int k = 1; k < m_Buttons.Count - 1; k++)
        {
            Button button = m_Buttons[k];
            SetupNavigation(button, m_Buttons[k - 1], m_Buttons[k + 1]);
        }

        //SetupNavigation(m_Buttons[0], BackButton, m_Buttons[1]);
        //SetupNavigation(m_Buttons[m_Buttons.Count - 1], m_Buttons[m_Buttons.Count - 2], null);
    }
 /// <summary>
 /// Equip new weapon
 /// </summary>
 public bool EquipWeapon(WeaponConfiguration weapon)
 {
     if (UnequipWeapon())
     {
         Equip(weapon);
         return(true);
     }
     return(false);
 }
Example #8
0
    void OnConfigurationReceived(WeaponConfiguration conf)
    {
        float value;

        if (conf.TryGetFloat(DelayParameterName, out value))
        {
            this.Delay = value;
        }
    }
Example #9
0
 public EventNode TimerTick(double numSeconds)
 {
     if (this.currentScreen == this.menuScreen)
     {
         if (this.menuScreen.Chosen)
         {
             if (this.menuScreen.Choice == "edit")
             {
                 this.showSelection();
             }
             else if (this.menuScreen.Choice == "test")
             {
                 this.showScreen(this.makeWorldScreen());
             }
             else if (this.menuScreen.Choice == "exit")
             {
                 this.cleanup();
                 return(this.NextNode);
             }
             this.menuScreen.Chosen = false;
         }
     }
     else if (this.currentScreen == this.selectionScreen)
     {
         if (this.selectionScreen.Chosen)
         {
             if (selectionScreen.Choice == null)
             {
                 this.showMenu();
             }
             else
             {
                 WeaponConfiguration weaponConfiguration = selectionScreen.Choice;
                 this.designScreen.Show(weaponConfiguration);
                 this.showScreen(designScreen);
             }
             this.selectionScreen.Chosen = false;
         }
     }
     else if (this.currentScreen == this.designScreen)
     {
         if (this.designScreen.Done)
         {
             this.showSelection();
         }
     }
     else if (this.currentScreen == this.worldScreen)
     {
         this.worldScreen.TimerTick(numSeconds);
         if (this.worldScreen.isPlayerSuccessful())
         {
             this.showMenu();
         }
     }
     return(this);
 }
Example #10
0
 /// <summary>
 /// Gets the weapon ships from the ship based on the specified configuration.
 /// </summary>
 public List <string> GetWeaponsList(WeaponConfiguration configuration)
 {
     if (configuration == WeaponConfiguration.Forward)
     {
         return(this.fixedWeapons);
     }
     else
     {
         return(this.turrentWeapons);
     }
 }
Example #11
0
 /// <summary>
 ///
 /// </summary>
 public void RemoveWeapon(WeaponConfiguration weaponConfig, string stringID)
 {
     if (weaponConfig == WeaponConfiguration.Forward)
     {
         RemoveWeaponFromList(fixedWeapons, stringID);
     }
     else
     {
         RemoveWeaponFromList(turrentWeapons, stringID);
     }
 }
Example #12
0
 /// <summary>
 /// Checks if all weapon arrays are full.
 /// </summary>
 public bool CheckIsFull(WeaponConfiguration configuration)
 {
     if (configuration == WeaponConfiguration.Forward)
     {
         return(this.fixedWeapons.Where(x => x == "").Count() == 0);
     }
     else
     {
         return(this.turrentWeapons.Where(x => x == "").Count() == 0);
     }
 }
Example #13
0
 /// <summary>
 /// Called to assign weapons to the specified weapon configuration.
 /// </summary>
 public void AssignWeapons(WeaponConfiguration weaponConfig, string weaponInstanceID)
 {
     if (weaponConfig == WeaponConfiguration.Forward)
     {
         AllocateWeaponToList(weaponInstanceID, this.fixedWeapons);
     }
     else if (weaponConfig == WeaponConfiguration.Turrent)
     {
         AllocateWeaponToList(weaponInstanceID, this.turrentWeapons);
     }
 }
Example #14
0
    void Start()
    {
        /* This is the right place for querying this component because at the time
         * of Awake () this object is usually not yet parented. */
        configuration = GetComponentInParent <WeaponConfiguration> ();

        if (SpawnOnStart)
        {
            SpawnObjects();
        }
    }
    /// <summary>
    /// Upgrade the weapon to next level
    /// </summary>
    /// <param name="id"></param>
    /// <param name="item"></param>
    public void UpgradeWeapon(LootItem item)
    {
        WeaponConfiguration weapon = item as WeaponConfiguration;

        weapon.currentLevel += 1;
        int l = weapon.currentLevel;

        weapon.MaxAmmoCapacity = weapon.levels[l - 1].maxAmmoCapacity;
        weapon.fireRate        = weapon.levels[l - 1].fireRate;
        weapon.damage          = weapon.levels[l - 1].damage;
        weapon.Clip.size       = weapon.levels[l - 1].clipSize;
    }
Example #16
0
        public void Show(WeaponConfiguration weaponConfiguration)
        {
            this.Done = false;
            this.weaponConfiguration = weaponConfiguration;
            this.getCanvas().Children.Clear();

            // TODO this screen could benefit from the VisiPlacer project too

            List <FrameworkElement> controls = new List <FrameworkElement>();

            TextBlock title = new TextBlock();

            title.Text = "Select up to " + this.weaponConfiguration.BasicWeapon.NumAugmentSlots + " augments for this weapon";
            Size size = this.getSize();

            controls.Add(title);

            this.identifyAvailableAugments();

            // Should we just use one ListView in multiselect mode?
            this.selectorViews = new List <ListView>();
            for (int i = 0; i < this.weaponConfiguration.BasicWeapon.NumAugmentSlots; i++)
            {
                ListView selector = new ListView();
                selector.SelectionMode     = SelectionMode.Single;
                selector.SelectionChanged += this.ListViewSelectionChanged;
                this.selectorViews.Add(selector);
            }


            foreach (ListView view in this.selectorViews)
            {
                controls.Add(view);
            }

            Button exitButton = new Button();

            exitButton.Content = "Back";
            exitButton.Click  += exitButton_Click;
            controls.Add(exitButton);

            double heightPerItem = size.Height / controls.Count;
            double y             = 0;

            foreach (FrameworkElement element in controls)
            {
                this.addControl(element, 0, y, size.Width, heightPerItem);
                y += heightPerItem;
            }

            this.makeSelectionsMatchWeapon();
        }
Example #17
0
    /// <summary>
    /// Check if the player has selected any starting weapons
    /// </summary>
    /// <returns>true if player has atleast one starting weapon</returns>
    public bool HasStartingWeapon()
    {
        for (int i = 0; i < GameManager.instance.StartingWeapons.Length; i++)
        {
            WeaponConfiguration weapon = GameManager.instance.StartingWeapons[i];
            if (weapon != null)
            {
                return(true);
            }
        }

        return(false);
    }
    /// <summary>
    /// Update the UI when the player purchases a weapon
    /// </summary>
    private void Update()
    {
        if (GameManager.instance.IsWeaponPurchased(previewItem.id, ItemList) && !UpgradeButton.gameObject.activeSelf)
        {
            WeaponConfiguration weapon = previewItem as WeaponConfiguration;

            UpgradeButton.gameObject.SetActive(true);
            PurchaseButton.gameObject.SetActive(false);
            ItemLockedImage.gameObject.SetActive(false);

            //UpgradeButton.interactable = GameManager.instance.Gold.CanAfford(weapon.levels[weapon.currentLevel].cost);
            UpgradeButton.interactable = false;
        }
    }
    private void Start()
    {
        if (GameManager.instance == null)
        {
            return;
        }

        audioSource = GetComponent <AudioSource>();

        ItemImage.sprite     = previewItem.itemSprite;
        CurrencyImage.sprite = previewItem.currencySprite;
        ItemName.text        = previewItem.itemName;
        Cost.text            = previewItem.itemCost.ToString();
        Level.text           = "Level " + previewItem.requiredLevel.ToString();

        if (previewItem.requiredLevel > GameManager.instance.GetPlayerLevel())
        {
            ItemLockedImage.gameObject.SetActive(true);
            PurchaseButton.gameObject.SetActive(false);
            UpgradeButton.gameObject.SetActive(false);
            Description.text = "DESCRIPTION NOT AVAILABLE AT THE MOMENT. REACH LEVEL " + previewItem.requiredLevel + " TO UNLOCK.";
        }
        else
        {
            if (previewItem.itemType == ItemType.Weapon)
            {
                WeaponConfiguration weapon = previewItem as WeaponConfiguration;
                if (GameManager.instance.IsWeaponPurchased(previewItem.id, ItemList))
                {
                    UpgradeButton.gameObject.SetActive(true);
                    PurchaseButton.gameObject.SetActive(false);
                    ItemLockedImage.gameObject.SetActive(false);

                    UpgradeButton.interactable = false;

                    /** if (weapon.levels.Length != 0 && !weapon.isAtMaxLevel)
                     * {
                     *   UpgradeButton.interactable = GameManager.instance.Gold.CanAfford(weapon.levels[weapon.currentLevel].cost);
                     * }
                     * else
                     * {
                     *   UpgradeButton.interactable = false;
                     * } **/
                }
                else
                {
                    PurchaseButton.gameObject.SetActive(true);
                    ItemLockedImage.gameObject.SetActive(false);
                    UpgradeButton.gameObject.SetActive(false);
                    Debug.Log("Not purchased");

                    PurchaseButton.interactable = GameManager.instance.Gold.CanAfford((int)weapon.itemCost);
                }
            }
            else
            {
                PurchaseButton.gameObject.SetActive(true);
                UpgradeButton.gameObject.SetActive(false);
                Level.gameObject.SetActive(false);
                ItemLockedImage.gameObject.SetActive(false);

                if (previewItem.currency == CurrencyType.Gems)
                {
                    PurchaseButton.interactable = GameManager.instance.Gems.CanAfford((int)previewItem.itemCost);
                }
                else
                {
                    PurchaseButton.interactable = GameManager.instance.Gold.CanAfford((int)previewItem.itemCost);
                }
            }
            Description.text = previewItem.itemDescription;
        }

        // Subscribe to currency change event
        GameManager.instance.Gold.currencyChanged += OnGoldChanged;
        GameManager.instance.Gems.currencyChanged += OnGemsChanged;
    }
Example #20
0
 protected virtual void Start()
 {
     configuration = GetComponentInParent <WeaponConfiguration> ();
 }
Example #21
0
        public Dictionary <WeaponAugmentTemplate, List <WeaponAugment> > GetAugmentsAssignableTo(WeaponConfiguration weaponConfiguration)
        {
            Dictionary <WeaponAugmentTemplate, List <WeaponAugment> > augments = new Dictionary <WeaponAugmentTemplate, List <WeaponAugment> >();

            foreach (WeaponAugmentTemplate template in this.weaponAugments.Keys)
            {
                List <WeaponAugment> assignableOfThisType = new List <WeaponAugment>();
                foreach (WeaponAugment augment in this.weaponAugments[template])
                {
                    if (augment.AssignedWeapon == null || augment.AssignedWeapon == weaponConfiguration)
                    {
                        assignableOfThisType.Add(augment);
                    }
                }
                if (assignableOfThisType.Count > 0)
                {
                    augments[template] = assignableOfThisType;
                }
            }
            return(augments);
        }
 private Packet CreateSetStatPacket(WeaponId weapon, WeaponConfiguration weaponConfiguration, WeaponSkillLevel skill)
 {
     throw new NotImplementedException();
 }
 public void SetWeaponConfigurationFor(WeaponId weapon, WeaponConfiguration weaponConfiguration, Player player, WeaponSkillLevel skill = WeaponSkillLevel.Poor)
 {
     SetWeaponConfigurationFor(weapon, weaponConfiguration, new Player[] { player }, skill);
 }
 public void SetWeaponConfigurationFor(WeaponId weapon, WeaponConfiguration weaponConfiguration, IEnumerable <Player> players, WeaponSkillLevel skill = WeaponSkillLevel.Poor)
 {
     CreateSetStatPacket(weapon, weaponConfiguration, skill).SendTo(players);
 }
Example #25
0
        public Clue RevealClue(int locationID, int gameID, int playerID)
        {
            Clue revealedClue = new Clue();

            using (ClueLessContext db = new ClueLessContext())
            {
                //Get the ClueLocation Object
                PositionToClue clue = db.PositionsToClues.Where(x => x.PositionID == locationID && x.GameID == gameID).FirstOrDefault();
                //Based on the clue type added the clue in the room to the player's  tracking table if it does not already exist
                int clueID = -1;
                switch (clue.ClueType)
                {
                case "Character":
                    //Look for the clue in the player's tracked character clues
                    clueID = db.PlayersToCharcters.Where(x => x.CharacterConfigurationID == clue.ClueID && x.PlayerID == playerID).Select(x => x.ID).FirstOrDefault();
                    //if it doesn't exist, add it to the player's tracker character clues
                    if (clueID <= 0)
                    {
                        db.PlayersToCharcters.Add(new PlayerToCharacter
                        {
                            PlayerID = playerID,
                            CharacterConfigurationID = clue.ClueID,
                        });
                        db.SaveChanges();
                    }
                    //Pull the information for the clue to be returned
                    CharacterConfiguration characterConfiguration = db.CharacterConfigurations.Where(x => x.ID == clue.ClueID).FirstOrDefault();
                    revealedClue = new Clue
                    {
                        ID   = characterConfiguration.ID,
                        Name = characterConfiguration.Character.Name,
                    };

                    break;

                case "Weapon":
                    //Look for the clue in the player's tracked weapon clues
                    clueID = db.PlayersToWeapons.Where(x => x.WeaponConfigurationID == clue.ClueID && x.PlayerID == playerID).Select(x => x.ID).FirstOrDefault();
                    //if it doesn't exist, add it to the player's tracked weapon clues
                    if (clueID <= 0)
                    {
                        db.PlayersToWeapons.Add(new PlayerToWeapon
                        {
                            PlayerID = playerID,
                            WeaponConfigurationID = clue.ClueID
                        });
                        db.SaveChanges();
                    }

                    //Pull the informaton for the clue to be returned
                    WeaponConfiguration weaponConfiguration = db.WeaponConfigurations.Where(x => x.ID == clue.ClueID).FirstOrDefault();
                    revealedClue = new Clue {
                        ID = weaponConfiguration.ID, Name = weaponConfiguration.Weapon.Name
                    };

                    break;

                case "Room":
                    clueID = db.PlayersToLocations.Where(x => x.PositionID == clue.ClueID && x.PlayerID == playerID).Select(x => x.ID).FirstOrDefault();
                    if (clueID > 0)
                    {
                        db.PlayersToLocations.Add(new PlayerToLocation
                        {
                            PlayerID   = playerID,
                            PositionID = clue.ClueID
                        });
                        db.SaveChanges();
                    }

                    //Pull the information for the clue to be returned
                    Position position = db.Positions.Where(x => x.ID == clue.ClueID).FirstOrDefault();
                    revealedClue = new Clue {
                        ID = position.ID, Name = position.Location.LocationName
                    };
                    break;

                default:
                    throw new ArgumentException();
                }

                // return the clue object
                return(revealedClue);
            }
        }
Example #26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="playerID">the ID of the player revealing the clue</param>
        /// <param name="clueID">The ID of the clue being revealed</param>
        /// <param name="ClueType">The Type of clue being revealed: Character, Weapon, Room</param>
        public static Clue RevealClue(int playerID, int clueID, string ClueType, int suggestionID)
        {
            Clue revealedClue = new Clue();

            try
            {
                using (ClueLessContext db = new ClueLessContext())
                {
                    //Get the database suggestion object
                    Database.DataModels.Suggestion suggestion = db.Suggestions.Where(x => x.ID == suggestionID).FirstOrDefault();

                    //Update the suggestion's author's clue tracker based on the clue type
                    switch (ClueType)
                    {
                    case "Character":
                        db.PlayersToCharcters.Add(new Database.DataModels.PlayerToCharacter
                        {
                            PlayerID = suggestion.PlayerID,
                            CharacterConfigurationID = clueID,
                        });
                        db.SaveChanges();

                        //Pull the information for the clue to be returned
                        CharacterConfiguration characterConfiguration = db.CharacterConfigurations.Where(x => x.ID == clueID).FirstOrDefault();
                        revealedClue = new Clue
                        {
                            ID   = characterConfiguration.ID,
                            Name = characterConfiguration.Character.Name,
                        };

                        break;

                    case "Weapon":
                        db.PlayersToWeapons.Add(new Database.DataModels.PlayerToWeapon
                        {
                            PlayerID = suggestion.PlayerID,
                            WeaponConfigurationID = clueID
                        });
                        db.SaveChanges();

                        WeaponConfiguration weaponConfiguration = db.WeaponConfigurations.Where(x => x.ID == clueID).FirstOrDefault();
                        revealedClue = new Clue {
                            ID = weaponConfiguration.ID, Name = weaponConfiguration.Weapon.Name
                        };

                        break;

                    case "Room":
                        db.PlayersToLocations.Add(new Database.DataModels.PlayerToLocation
                        {
                            PlayerID   = suggestion.PlayerID,
                            PositionID = clueID
                        });
                        db.SaveChanges();

                        //Pull the information for the clue to be returned
                        Position position = db.Positions.Where(x => x.ID == clueID).FirstOrDefault();
                        revealedClue = new Clue {
                            ID = position.ID, Name = position.Location.LocationName
                        };

                        break;

                    default:
                        throw new ArgumentException();
                    }
                }
            }catch (Exception e)
            {
                Console.WriteLine(e.Message + Environment.NewLine + e.StackTrace);
            }

            return(revealedClue);
        }