Ejemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     if (ui_hotbar == null)
     {
         ui_hotbar = FindObjectOfType <HotBar>();
     }
 }
Ejemplo n.º 2
0
        public static void Load()
        {
            _inventory = new Inventory();
            ButtonBar  = new ButtonBar();
            HotBar.Initialize();
            _minimap = new Minimap();
            _minimap.StartUpdating();

            for (var i = 1; i <= Construction.Length; i++)
            {
                Construction[i - 1] = new SoundFx("Sounds/Level Editor/construct" + i);
            }
            _destruction = new SoundFx("Sounds/Level Editor/destroy1");

            _wallMode = new SoundFx("Sounds/Level Editor/changeMode");
            _close    = new SoundFx("Sounds/Level Editor/open");
            _open     = new SoundFx("Sounds/Level Editor/close");
            _select   = new SoundFx("Sounds/Level Editor/select");


            foreach (Player player in GameWorld.GetPlayers())
            {
                player.SetPosition(player.RespawnPos);
            }

            Cursor.Show();
        }
Ejemplo n.º 3
0
    public void LoadSpells(List <Item.Types> spells)
    {
        List <Item> spellItems = new List <Item>();

        foreach (Item.Types spell in spells)
        {
            Item spellItem = Item.Factory(spell);
            if (spellItem == null)
            {
                GD.Print("SpellCaster.LoadSpells: Could not create spell " + spell);
            }
            else
            {
                spellItems.Add(spellItem);
            }
        }

        hotbar = new HotBar(spellItems.Count);

        for (int i = 0; i < spellItems.Count; i++)
        {
            hotbar.SetItemSlot(i, spellItems[i]);
            AddChild(spellItems[i]);
            spellItems[i].Equip(this);
            spellItems[i].Mode = RigidBody.ModeEnum.Static;
        }
    }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates all UI components and checks for input.
        /// </summary>
        public static void Update()
        {
            if (GameDebug.IsTyping)
            {
                return;
            }

            foreach (Player player in GameWorld.GetPlayers())
            {
                player.Health = player.MaxHealth;
            }

            SoundtrackManager.PlayLevelEditorTheme();

            _inventory.Update();
            ButtonBar.Update();
            HotBar.Update();
            Brush.Update();
            CheckIfOnInventory();
            CheckIfPositioningPlayer();
            CheckIfChangedToWallMode();
            CheckForCameraMovement();
            CheckForMouseInput();

            ForceUpdateTile?.Update();

            // Auto-save functionality.
            if (IdleTimerForSave.TimeElapsedInSeconds > 1 && _hasChangedSinceLastSave)
            {
                SaveLevel();
            }
        }
Ejemplo n.º 5
0
        public override void Draw(GameTime time)
        {
            // While transitioning all black
            if (transitionMs > 0)
            {
                SpriteBatch.GraphicsDevice.Clear(Color.Black);
                return;
            }

            int bgW = sprBackground.Width;
            int bgH = TileMap.getPixelHeight();

            int bgX = offset.X % (bgW * 2);
            int bgY = offset.Y % (bgH * 2);

            SpriteBatch.Draw(sprBackground, new Rectangle(bgX, bgY, bgW, bgH), Color.White);

            // # Draw a second one in front of first to wrap around
            bgX += bgW;
            SpriteBatch.Draw(sprBackground, new Rectangle(bgX, bgY, bgW, bgH), Color.White);

            // Draw map
            TileMap.draw(SpriteBatch, offset, time.ElapsedGameTime);

            // Draw hotbar
            HotBar.draw(SpriteBatch);
        }
Ejemplo n.º 6
0
 public Player(Vector2 spawnPoint, string username, GuiInventory inventory)
     : base(new Rectangle((int) spawnPoint.X, (int) spawnPoint.Y, Tile.Tile_Width, Tile.Tile_Width * 2), Textures.EntityPlayer, 1, 2.8f, true, Tile.Tile_Width + 10)
 {
     this.username = username;
     this.spawnPoint = spawnPoint;
     this.inventory = inventory;
     hotbar = new HotBar();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Draws on screen.
 /// </summary>
 /// <param name="spriteBatch"></param>
 public static void DrawUi(SpriteBatch spriteBatch)
 {
     _minimap.Draw(spriteBatch);
     _inventory.Draw(spriteBatch);
     ButtonBar.Draw(spriteBatch);
     HotBar.Draw(spriteBatch);
     _inventory.DrawOnTop(spriteBatch);
 }
Ejemplo n.º 8
0
    public override void OnStartClient()
    {
        if (GameObject.Find("Hotbar") != null)
        {
            hotbar = GameObject.Find("Hotbar").GetComponent <HotBar>();
        }

        ShipTooltip.SetActive(false);
    }
Ejemplo n.º 9
0
 public void LoadStats(StatsManager stats)
 {
     GD.Print("Loading stats " + stats.GetFact(StatsManager.Facts.Name));
     hotbar = new HotBar(stats);
     if (hotbar != null && hotbar.EquipItem(0) != null)
     {
         DeferredEquipItem(hotbar.EquipItem(0));
     }
     this.stats = stats;
     Brains brain = (Brains)stats.GetStat(StatsManager.Stats.Brain);
 }
Ejemplo n.º 10
0
        public Player(SerializationInfo info, StreamingContext cntxt) : base(info, cntxt)
        {
            nextLevelXP = (int)info.GetValue("Player_Lvlxp", typeof(int));
            xp          = (int)info.GetValue("Player_Xp", typeof(int));
            items       = (Item[])info.GetValue("Player_Items", typeof(Item[]));
            RoomCount   = (int)info.GetValue("Player_RoomCount", typeof(int));
            HotBar      = (HotBar)info.GetValue("Player_HotBar", typeof(HotBar));

            // Unsaved stuff
            aliveSpells = new List <Attack>();
        }
Ejemplo n.º 11
0
        public Player(GameScreen screen, int x, int y, String name, Sprite s) : base(screen, s, x, y, 900)
        {
            this.xp          = 0;
            this.nextLevelXP = 33;

            this.Name      = name;
            this.RoomCount = 0;

            HotBar      = new HotBar();
            aliveSpells = new List <Attack>();
            items       = new Item[this.inventorySize()];
        }
Ejemplo n.º 12
0
 // Use this for initialization
 void Start()
 {
     HB = player.GetComponent <HotBar>();
     // placetoreturnto = this.transform;
     for (int i = 0; i < icons.Length; i++)
     {
         printVector(icons[i].rectTransform.position);
         StartTransforms[i] = icons[i].rectTransform.position;
     }
     for (int i = 0; i < icons.Length; i++)
     {
         desiredLocs[i] = new Vector3(StartTransforms[i].x + movex, StartTransforms[i].y + movey, 0.0f);
     }
 }
Ejemplo n.º 13
0
        //Base class for each individual class!
        protected PlayerClass()
        {
            HotBar.RefreshHotbar();
            HotBar.RefreshPassives();
            HotBar.UpdateRepeatAbilityTimes();

            Skill healthPotionSkill = new DrinkHealthPotion();

            AbilityLogicConditions.CreateAbilityLogicConditions(ref healthPotionSkill);
            HealthPotionAbility = (DrinkHealthPotion)healthPotionSkill;

            LastUsedAbility = DefaultAttack;
            PowerPrime      = DefaultAttack;
            Logger.DBLog.InfoFormat("[Funky] Finished Creating Player Class");
        }
Ejemplo n.º 14
0
        /////////////////////////
        ///

        private void ResolveDependencies()
        {
            if (_itemsParent == null)
            {
                _itemsParent = _items[0].transform.parent.gameObject;
            }

            if (_inventory == null)
            {
                _inventory = FindObjectOfType <ItemInventoryMenu>();
            }

            if (_hotBar == null)
            {
                _hotBar = FindObjectOfType <HotBar>();
            }
        }
Ejemplo n.º 15
0
        ///<summary>
        ///Used to check for a secondary hotbar set. Currently only used for wizards with Archon.
        ///</summary>
        internal override bool SecondaryHotbarBuffPresent()
        {
            bool ArchonBuffPresent = HotBar.HasBuff(SNOPower.Wizard_Archon);

            //Confirm we don't have archon Ability without archon buff.
            bool RefreshNeeded = ((!ArchonBuffPresent && Abilities.ContainsKey(SNOPower.Wizard_Archon_ArcaneBlast)) ||
                                  (ArchonBuffPresent && !Abilities.ContainsKey(SNOPower.Wizard_Archon_ArcaneBlast)));

            if (RefreshNeeded)
            {
                Logger.DBLog.InfoFormat("Updating Hotbar abilities!");
                HotBar.CachedPowers = new HashSet <SNOPower>(HotBar.HotbarPowers);
                HotBar.RefreshHotbar();
                HotBar.UpdateRepeatAbilityTimes();
                RecreateAbilities();
                return(true);
            }

            return(false);
        }
Ejemplo n.º 16
0
        public override void Update(GameTime time)
        {
            // Don't run until player is created
            if (Player == null)
            {
                return;
            }

            // Don't do anything while transitioning
            if (transitionMs > 0)
            {
                transitionMs -= time.ElapsedGameTime.Milliseconds;
                return;
            }

            // ### Movement input
            if (ScreenManager.kbState.IsKeyDown(Keys.Right) && !ScreenManager.kbState.IsKeyDown(Keys.Left))
            {
                Player.doMove(Direction.Right);
            }
            else if (!ScreenManager.kbState.IsKeyDown(Keys.Right) && ScreenManager.kbState.IsKeyDown(Keys.Left))
            {
                Player.doMove(Direction.Left);
            }
            else
            {
                Player.doMove(Direction.Stopped);
            }

            // ### Jump/Duck input
            if (ScreenManager.kbState.IsKeyDown(Keys.Space))
            {
                Player.doJump();
            }
            else if (!ScreenManager.kbState.IsKeyDown(Keys.Space) && ScreenManager.kbState.IsKeyDown(Keys.Down) && !ScreenManager.kbState.IsKeyDown(Keys.Up))
            {
                Player.doDuck();
            }
            else if (!ScreenManager.kbState.IsKeyDown(Keys.Space) && !ScreenManager.kbState.IsKeyDown(Keys.Down) && ScreenManager.kbState.IsKeyDown(Keys.Up))
            {
                Player.doBlock();
            }
            else if (Player.State == EntityState.Crouching || Player.State == EntityState.Blocking)
            {
                Player.stand();
            }

            // ### Attack input
            if (ScreenManager.kbState.IsKeyDown(Keys.Q))
            {
                Player.doAttack(TileMap, EntityPart.Head);
            }
            else if (ScreenManager.kbState.IsKeyDown(Keys.W))
            {
                Player.doAttack(TileMap, EntityPart.Body);
            }
            else if (ScreenManager.kbState.IsKeyDown(Keys.E))
            {
                Player.doAttack(TileMap, EntityPart.Legs);
            }

            // ### Hotbat input
            if (ScreenManager.kbState.IsKeyDown(Keys.D1))
            {
                HotBar.select(0);
            }
            else if (ScreenManager.kbState.IsKeyDown(Keys.D2))
            {
                HotBar.select(1);
            }
            else if (ScreenManager.kbState.IsKeyDown(Keys.D3))
            {
                HotBar.select(2);
            }
            else if (ScreenManager.kbState.IsKeyDown(Keys.D4))
            {
                HotBar.select(3);
            }
            else if (ScreenManager.kbState.IsKeyDown(Keys.D5))
            {
                HotBar.select(4);
            }
            else if (ScreenManager.kbState.IsKeyDown(Keys.D6))
            {
                HotBar.select(5);
            }
            else if (ScreenManager.kbState.IsKeyDown(Keys.D7))
            {
                HotBar.select(6);
            }
            else if (ScreenManager.kbState.IsKeyDown(Keys.D8))
            {
                HotBar.select(7);
            }
            else if (ScreenManager.kbState.IsKeyDown(Keys.D9))
            {
                HotBar.select(8);
            }
            HotBar.update(time.ElapsedGameTime);

            // Interact with tile block
            if (ScreenManager.kbState.IsKeyDown(Keys.Enter) && ScreenManager.oldKBState.IsKeyUp(Keys.Enter))
            {
                Rectangle rect = Player.EBounds.Rect;
                TileMap.getPixel(rect.Center.X, rect.Center.Y).interact(this);
            }

            // Update tilemap
            TileMap.update(time.ElapsedGameTime);

            // ### Offset
            offset.X = (int)(Player.Location.X - getScreenManager().Width / 2);
            if (offset.X < 0)
            {
                offset.X = 0;
            }
            else if (offset.X + getScreenManager().Width > TileMap.getPixelWidth())
            {
                offset.X = (int)(TileMap.getPixelWidth() - getScreenManager().Width);
            }
            offset.X *= -1; // Invert

            offset.Y = (int)(Player.Location.Y - getScreenManager().Height / 2);
            if (offset.Y < 0)
            {
                offset.Y = 0;
            }
            else if (offset.Y + getScreenManager().Height > TileMap.getPixelHeight())
            {
                offset.Y = (int)(TileMap.getPixelHeight() - getScreenManager().Height);
            }
            offset.Y *= -1; // Invert

            oldKb = ScreenManager.kbState;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Checks for input to draw, erase or select tiles using the mouse.
        /// </summary>
        private static void CheckForMouseInput()
        {
            _mouseRectInGameWorld = InputSystem.GetMouseRectGameWorld();
            IndexOfMouse          = CalcHelper.GetIndexInGameWorld(_mouseRectInGameWorld.X, _mouseRectInGameWorld.Y);

            if (!IsIntersectingUi())
            {
                if (InputSystem.IsLeftMousePressed() && InputSystem.IsRightMousePressed())
                {
                    return;
                }

                if (InputSystem.IsLeftMousePressed())
                {
                    if (Brush.CurrentBrushMode == Brush.BrushMode.Build && lastAddedTile != IndexOfMouse)
                    {
                        lastAddedTile   = IndexOfMouse;
                        lastRemovedTile = -1;
                        UpdateSelectedTiles(SelectedId);
                    }
                    else if (Brush.CurrentBrushMode == Brush.BrushMode.Erase && lastRemovedTile != IndexOfMouse)
                    {
                        lastRemovedTile = IndexOfMouse;
                        lastAddedTile   = -1;
                        UpdateSelectedTiles(0);
                    }
                    else if (Brush.CurrentBrushMode == Brush.BrushMode.Select)
                    {
                        Tile tile = GameWorld.GetTile(IndexOfMouse);
                        tile.InteractInEditMode();
                    }
                }
                if (InputSystem.IsRightMousePressed())
                {
                    if (!OnWallMode)
                    {
                        ChangeWallModeTo(true);
                    }
                    if (Brush.CurrentBrushMode == Brush.BrushMode.Build && lastAddedTile != IndexOfMouse)
                    {
                        // Entities cannot be placed in wall mode.
                        if ((int)SelectedId < 200)
                        {
                            lastAddedTile   = IndexOfMouse;
                            lastRemovedTile = -1;
                            UpdateSelectedTiles(SelectedId);
                        }
                    }
                    else if (Brush.CurrentBrushMode == Brush.BrushMode.Erase && lastRemovedTile != IndexOfMouse)
                    {
                        lastRemovedTile = IndexOfMouse;
                        lastAddedTile   = -1;
                        UpdateSelectedTiles(0);
                    }
                }
                else if (InputSystem.IsMiddleMousePressed())
                {
                    TileType lastSelectedId = SelectedId;
                    SelectedId = GameWorld.WorldData.TileIDs[IndexOfMouse];
                    if (SelectedId == 0)
                    {
                        SelectedId = GameWorld.WorldData.WallIDs[IndexOfMouse];
                    }
                    if (SelectedId != 0)
                    {
                        HotBar.AddToHotBarFromWorld(SelectedId);
                        Brush.ChangeBrushMode(Brush.BrushMode.Build);
                    }
                    else
                    {
                        SelectedId = lastSelectedId;
                    }
                }
                else
                {
                    if (OnWallMode)
                    {
                        ChangeWallModeTo(false);
                    }
                }
            }
        }
Ejemplo n.º 18
0
 //! This class contains all functions called by the input manager.
 public ActionManager(PlayerController playerController)
 {
     this.playerController = playerController;
     hotbar      = playerController.gameObject.GetComponent <HotBar>();
     meshManager = playerController.gameManager.meshManager;
 }
Ejemplo n.º 19
0
 private void Start()
 {
     HB = HBGO.GetComponent <HotBar>();
 }
Ejemplo n.º 20
0
 public SpellCaster()
 {
     hotbar = new HotBar(0);
 }