public int GetDefaultBagIndex(PlayerInfoComponent playerInfoComponent)
        {
            if (playerInfoComponent == null || playerInfoComponent.WeaponBags == null || playerInfoComponent.WeaponBags.Length == 0)
            {
                return(0);
            }
            int fullBagIndex  = -1;
            int emptyBagIndex = -1;

            foreach (var bagData in playerInfoComponent.WeaponBags)
            {
                if (bagData == null || bagData.weaponList == null)
                {
                    continue;
                }
                if (bagData.weaponList != null && bagData.weaponList.Count > 0)
                {
                    fullBagIndex = fullBagIndex > -1 ? Math.Min(fullBagIndex, bagData.BagIndex) : bagData.BagIndex;
                }
                else
                {
                    emptyBagIndex = emptyBagIndex > -1 ? Math.Min(emptyBagIndex, bagData.BagIndex) : bagData.BagIndex;
                }
            }
            DebugUtil.MyLog(fullBagIndex > -1 ? fullBagIndex : emptyBagIndex);
            return(fullBagIndex > -1 ? fullBagIndex : emptyBagIndex);
        }
Esempio n. 2
0
    void Awake()
    {
        m_PlayerMovementComponentToDisplay = Utils.FindComponentMatchingWithTag <PlayerMovementComponent>(m_Target.ToString());
        m_PlayerAttackComponentToDisplay   = Utils.FindComponentMatchingWithTag <PlayerAttackComponent>(m_Target.ToString());
        m_PlayerInfoComponentToDisplay     = Utils.FindComponentMatchingWithTag <PlayerInfoComponent>(m_Target.ToString());

        m_DebugSettings = ScenesConfig.GetDebugSettings();
        m_GameInputList.SetActive(m_DebugSettings.m_DisplayInputsInfo);

        m_TriggeredInputs = new List <List <GameInput> >(m_GameInputList.transform.childCount);
        m_GameInputsImage = new List <List <Image> >(m_GameInputList.transform.childCount);
        for (int i = 0; i < m_GameInputList.transform.childCount; i++)
        {
            List <Image> gameInputImageList = new List <Image>();
            Transform    gameInputs         = m_GameInputList.transform.GetChild(i);
            for (int j = 0; j < gameInputs.childCount; j++)
            {
                Image gameInputImage = gameInputs.GetChild(j).GetComponent <Image>();
                gameInputImage.sprite  = null;
                gameInputImage.enabled = false;
                gameInputImageList.Add(gameInputImage);
            }

            m_GameInputsImage.Add(gameInputImageList);
        }

#if !UNITY_EDITOR
        m_TextInputs.enabled                = false;
        m_TextToDisplayInputs.enabled       = false;
        m_TextInputsAttack.enabled          = false;
        m_TextToDisplayInputsAttack.enabled = false;
        m_TextAttacks.enabled               = false;
        m_TextToDisplayAttacks.enabled      = false;
#endif
    }
 public int GetUsableWeapnBagLength(PlayerInfoComponent playerInfoComponent)
 {
     if ((EGameMode)ModeId == EGameMode.Survival || playerInfoComponent.WeaponBags == null ||
         playerInfoComponent.WeaponBags.Length == 0)
     {
         return(1);
     }
     return(playerInfoComponent.WeaponBags.Length);
 }
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (stateInfo.normalizedTime >= 1.0f && !m_EndOfRoundAnim)
     {
         PlayerInfoComponent infoComponent = animator.transform.root.GetComponent <PlayerInfoComponent>();
         Utils.GetPlayerEventManager(animator.gameObject).TriggerEvent(EPlayerEvent.EndOfRoundAnimation, new EndOfRoundAnimationEventParameters(infoComponent.GetPlayerEnum()));
         m_EndOfRoundAnim = true;
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Updates weapons currently in the game.
        /// </summary>
        /// <param name="elapsedTime"></param>
        public void Update(float elapsedTime)
        {
            _playerInfoComponent = _game.PlayerInfoComponent;
            _timer += elapsedTime;
            bool spriteRemoved = false;
            Equipment equipment;
            Weapon weapon;
            bool attacking;
            bool collisionCreated;

            foreach (Player player in _game.PlayerComponent.All)
            {
                equipment = _equipmentComponent[player.EntityID];
                attacking = _playerInfoComponent[player.EntityID].State == PlayerState.Attacking;
                weapon = _weaponComponent[equipment.WeaponID];
                collisionCreated = _collisionComponent.Contains(equipment.WeaponID);

                //Handle sprites
                if (_weaponSpriteComponent.Contains(player.EntityID))
                {
                    //If the player has a weapon sprite update it
                    spriteRemoved = UpdateWeaponSprite(_weaponSpriteComponent[player.EntityID]);
                }
                else if (attacking)
                {
                    //Otherwise create a new sprite and sound.
                    _game.WeaponFactory.CreateWeaponSprite(equipment.WeaponID, equipment.EntityID);
                    PlayWeaponSound(equipment.WeaponID);
                }

                //Handle more weapon logic.
                if(attacking)
                {
                    if (weapon.AttackType == WeaponAttackType.Ranged)
                    {
                        _bulletTimer += elapsedTime;
                        if (_bulletTimer >= weapon.Speed)
                        {
                            CreateBulletAndSprite(equipment.EntityID, equipment.WeaponID);
                            _bulletTimer = 0;
                        }
                    }
                    else
                    {
                        if (collisionCreated)
                            UpdateWeaponCollision(equipment.EntityID, equipment.WeaponID);
                        else
                            CreateWeaponCollision(equipment.EntityID, equipment.WeaponID);
                    }
                }
                else if (collisionCreated) //Not attacking but the collision box is there.
                {
                    _collisionComponent.Remove(equipment.WeaponID);
                }
            }
        }
Esempio n. 6
0
 public virtual void OnInit(PlayerAttackComponent playerAttackComponent, PlayerAttack attack)
 {
     m_Owner             = playerAttackComponent.gameObject;
     m_Attack            = attack;
     m_Animator          = playerAttackComponent.m_Animator;
     m_MovementComponent = playerAttackComponent.m_MovementComponent;
     m_AttackComponent   = playerAttackComponent;
     m_InfoComponent     = playerAttackComponent.m_InfoComponent;
     m_AudioManager      = playerAttackComponent.m_AudioManager;
 }
Esempio n. 7
0
        protected override void OnRender(Entitas.Entity entity)
        {
            base.OnRender(entity);

            PlayerInfoComponent com = entity.GetComponent <PlayerInfoComponent>();

            if (com != null)
            {
                m_Txt.text = com.Value.ToString();
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Creates this system.
        /// </summary>
        /// <param name="game"></param>
        public WeaponSystem(DungeonCrawlerGame game)
        {
            _game = game;

            //To simplfy some things, I'm keeping a reference to components I often use.
            _collisionComponent = _game.CollisionComponent;
            _equipmentComponent = _game.EquipmentComponent;
            _playerInfoComponent = _game.PlayerInfoComponent;
            _weaponComponent = _game.WeaponComponent;
            _weaponSpriteComponent = _game.WeaponSpriteComponent;
            _positionComponent = _game.PositionComponent;
        }
        /// <summary>
        /// Creates this system.
        /// </summary>
        /// <param name="game"></param>
        public WeaponSystem(DungeonCrawlerGame game)
        {
            _game = game;

            //To simplfy some things, I'm keeping a reference to components I often use.
            _collisionComponent    = _game.CollisionComponent;
            _equipmentComponent    = _game.EquipmentComponent;
            _playerInfoComponent   = _game.PlayerInfoComponent;
            _weaponComponent       = _game.WeaponComponent;
            _weaponSpriteComponent = _game.WeaponSpriteComponent;
            _positionComponent     = _game.PositionComponent;
        }
Esempio n. 10
0
    void InitPalette()
    {
        GameObject owner = m_Logic.GetOwner();

        if (owner != null)
        {
            PlayerInfoComponent infoComp = owner.GetComponent <PlayerInfoComponent>();
            if (infoComp != null)
            {
                infoComp.InitWithCurrentPalette(m_SpriteRenderer.material);
            }
        }
    }
Esempio n. 11
0
    private void OnPlayerRegistered(GameObject player)
    {
        PlayerInfoComponent infoComponent = player.GetComponent <PlayerInfoComponent>();

        if (infoComponent != null)
        {
            m_PlayerName.SetText(infoComponent.m_InfoConfig.m_PlayerName);
            m_PlayerIcon.sprite = infoComponent.m_InfoConfig.m_PlayerIcon;

            Material instianciatedMaterial = Instantiate(m_PlayerIcon.material); // By default Image material is shared...
            infoComponent.InitWithCurrentPalette(instianciatedMaterial);
            m_PlayerIcon.material = instianciatedMaterial;
        }
    }
    public PlayerSuperGaugeSubComponent(PlayerInfoComponent infoComp) : base(infoComp.gameObject)
    {
        m_InfoComponent = infoComp;

        if (m_InfoComponent.GetPlayerSettings().SuperGaugeAlwaysFilled)
        {
            IncreaseGaugeValue(AttackConfig.Instance.m_SuperGaugeMaxValue);
        }
        else
        {
            IncreaseGaugeValue(GameManager.Instance.GetSubManager <RoundSubGameManager>(ESubManager.Round).GetPlayerSuperGaugeValue(m_InfoComponent.GetPlayerEnum()));
        }
        m_InfoComponent.GetPlayerSettings().OnSuperGaugeAlwaysFilledChanged += OnSuperGaugeAlwaysFilledChanged;
    }
        public List <PlayerWeaponBagData> FilterSortedWeaponBagDatas(PlayerInfoComponent playerInfoComponent,
                                                                     GamePlayComponent gamePlayComponent)
        {
            var list         = new List <PlayerWeaponBagData>();
            var jobAttribute = (gamePlayComponent == null
                            ? (int)EJobAttribute.EJob_EveryMan
                            : gamePlayComponent.JobAttribute);

            if (jobAttribute == (int)EJobAttribute.EJob_Variant || jobAttribute == (int)EJobAttribute.EJob_Matrix)
            {
                var originList = PlayerEntityFactory.MakeVariantWeaponBag();
                for (int i = 0; i < originList.Length; i++)
                {
                    list.Add(originList[i]);
                }
            }
            else
            {
                var originList = playerInfoComponent.WeaponBags;
                for (int i = 0; i < originList.Length; i++)
                {
                    if (originList[i] == null)
                    {
                        continue;
                    }
                    Logger.InfoFormat("Server Origin Data =====>add BagIndex:{0}", originList[i].BagIndex);
                    list.Add(originList[i]);
                    //    ServerRoomWeaponPreLog(playerInfoComponent.WeaponBags);
                    //    if ((EGameMode)ModeId == EGameMode.Survival) return null;
                    //    if (playerInfoComponent.WeaponBags == null ||
                    //playerInfoComponent.WeaponBags.Length == 0) return null;
                    //    var valuableBagDatas = new List<PlayerWeaponBagData>(playerInfoComponent.WeaponBags);
                    //    for (int i = valuableBagDatas.Count - 1; i >= 0; i--)
                    //    {
                    //        if (valuableBagDatas[i] == null || valuableBagDatas[i].weaponList.Count == 0 ||
                    //          valuableBagDatas[i].BagIndex > GlobalConst.WeaponBagMaxCount)
                    //        {
                    //            valuableBagDatas.RemoveAt(i);
                    //            continue;
                    //        }
                    //   //     DebugUtil.LogInUnity("Server init bag item:"+valuableBagDatas[i].ToString(),DebugUtil.DebugColor.Blue);
                    //    }
                    //    valuableBagDatas.Sort(ModeUtil.RoomWeaponCompareCmd);

                    //    return valuableBagDatas;
                }
            }

            return(list);
        }
Esempio n. 14
0
        void DoingInersectsImpl(Entity e1, Entity e2)
        {
            if (e1 == null || e2 == null)
            {
                return;
            }
            PlayerInfoComponent playerInfo = e1.GetComponent <PlayerInfoComponent>();

            if (playerInfo != null)
            {
                IntValueComponent intvalue = e2.GetComponent <IntValueComponent>();
                if (intvalue != null)
                {
                    playerInfo.Value += intvalue.Value;
                    list.Add(e2.Id);
                }
            }
        }
Esempio n. 15
0
    public static void SetTriggerPointStatus(PlayerInfoComponent infoComponent, ETriggerPointStatus status)
    {
        if (status == ETriggerPointStatus.Inactive)
        {
            if (m_TriggerPointStatus[infoComponent.GetPlayerIndex()] == ETriggerPointStatus.Triggered)
            {
                infoComponent.ResetDefaultAndCurrentPalette();
            }

            if (infoComponent.GetPlayerSettings().TriggerPointAlwaysActive)
            {
                status = ETriggerPointStatus.Active;
            }
        }

        m_TriggerPointStatus[infoComponent.GetPlayerIndex()] = status;
        OnTriggerPointStatusChanged[infoComponent.GetPlayerIndex()]?.Invoke(status);
    }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory = new AggregateFactory(this);
            WeaponFactory = new WeaponFactory(this);
            DoorFactory = new DoorFactory(this);
            RoomFactory = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory = new WallFactory(this);
            EnemyFactory = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory = new NPCFactory(this);

            // Initialize Components
            PlayerComponent = new PlayerComponent();
            LocalComponent = new LocalComponent();
            RemoteComponent = new RemoteComponent();
            PositionComponent = new PositionComponent();
            MovementComponent = new MovementComponent();
            MovementSpriteComponent = new MovementSpriteComponent();
            SpriteComponent = new SpriteComponent();
            DoorComponent = new DoorComponent();
            RoomComponent = new RoomComponent();
            HUDSpriteComponent = new HUDSpriteComponent();
            HUDComponent = new HUDComponent();
            InventoryComponent = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent = new EquipmentComponent();
            WeaponComponent = new WeaponComponent();
            BulletComponent = new BulletComponent();
            PlayerInfoComponent = new PlayerInfoComponent();
            WeaponSpriteComponent = new WeaponSpriteComponent();
            StatsComponent = new StatsComponent();
            EnemyAIComponent = new EnemyAIComponent();
            NpcAIComponent = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent = new CollisionComponent();
            TriggerComponent = new TriggerComponent();
            EnemyComponent = new EnemyComponent();
            NPCComponent = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent = new SoundComponent();
            ActorTextComponent = new ActorTextComponent();
            TurretComponent = new TurretComponent();
            TrapComponent = new TrapComponent();
            ExplodingDroidComponent = new ExplodingDroidComponent();
            HealingStationComponent = new HealingStationComponent();
            PortableShieldComponent = new PortableShieldComponent();
            PortableStoreComponent = new PortableStoreComponent();
            ActiveSkillComponent = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();

            Quests = new List<Quest>();

            #region Initialize Effect Components
            AgroDropComponent = new AgroDropComponent();
            AgroGainComponent = new AgroGainComponent();
            BuffComponent = new BuffComponent();
            ChanceToSucceedComponent = new ChanceToSucceedComponent();
            ChangeVisibilityComponent = new ChangeVisibilityComponent();
            CoolDownComponent = new CoolDownComponent();
            DamageOverTimeComponent = new DamageOverTimeComponent();
            DirectDamageComponent = new DirectDamageComponent();
            DirectHealComponent = new DirectHealComponent();
            FearComponent = new FearComponent();
            HealOverTimeComponent = new HealOverTimeComponent();
            InstantEffectComponent = new InstantEffectComponent();
            KnockBackComponent = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent = new ReduceAgroRangeComponent();
            ResurrectComponent = new ResurrectComponent();
            StunComponent = new StunComponent();
            TimedEffectComponent = new TimedEffectComponent();
            EnslaveComponent = new EnslaveComponent();
            CloakComponent = new CloakComponent();
            #endregion

            base.Initialize();
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory   = new AggregateFactory(this);
            WeaponFactory      = new WeaponFactory(this);
            DoorFactory        = new DoorFactory(this);
            RoomFactory        = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory        = new WallFactory(this);
            EnemyFactory       = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory         = new NPCFactory(this);

            // Initialize Components
            PlayerComponent          = new PlayerComponent();
            LocalComponent           = new LocalComponent();
            RemoteComponent          = new RemoteComponent();
            PositionComponent        = new PositionComponent();
            MovementComponent        = new MovementComponent();
            MovementSpriteComponent  = new MovementSpriteComponent();
            SpriteComponent          = new SpriteComponent();
            DoorComponent            = new DoorComponent();
            RoomComponent            = new RoomComponent();
            HUDSpriteComponent       = new HUDSpriteComponent();
            HUDComponent             = new HUDComponent();
            InventoryComponent       = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen    = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent       = new EquipmentComponent();
            WeaponComponent          = new WeaponComponent();
            BulletComponent          = new BulletComponent();
            PlayerInfoComponent      = new PlayerInfoComponent();
            WeaponSpriteComponent    = new WeaponSpriteComponent();
            StatsComponent           = new StatsComponent();
            EnemyAIComponent         = new EnemyAIComponent();
            NpcAIComponent           = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent   = new CollisionComponent();
            TriggerComponent     = new TriggerComponent();
            EnemyComponent       = new EnemyComponent();
            NPCComponent         = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager             = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent        = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent           = new SoundComponent();
            ActorTextComponent       = new ActorTextComponent();
            TurretComponent          = new TurretComponent();
            TrapComponent            = new TrapComponent();
            ExplodingDroidComponent  = new ExplodingDroidComponent();
            HealingStationComponent  = new HealingStationComponent();
            PortableShieldComponent  = new PortableShieldComponent();
            PortableStoreComponent   = new PortableStoreComponent();
            ActiveSkillComponent     = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();
            MatchingPuzzleComponent  = new MatchingPuzzleComponent();
            pI = new PlayerInfo();

            Quests = new List <Quest>();


            #region Initialize Effect Components
            AgroDropComponent          = new AgroDropComponent();
            AgroGainComponent          = new AgroGainComponent();
            BuffComponent              = new BuffComponent();
            ChanceToSucceedComponent   = new ChanceToSucceedComponent();
            ChangeVisibilityComponent  = new ChangeVisibilityComponent();
            CoolDownComponent          = new CoolDownComponent();
            DamageOverTimeComponent    = new DamageOverTimeComponent();
            DirectDamageComponent      = new DirectDamageComponent();
            DirectHealComponent        = new DirectHealComponent();
            FearComponent              = new FearComponent();
            HealOverTimeComponent      = new HealOverTimeComponent();
            PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent();
            InstantEffectComponent     = new InstantEffectComponent();
            KnockBackComponent         = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent   = new ReduceAgroRangeComponent();
            ResurrectComponent         = new ResurrectComponent();
            StunComponent              = new StunComponent();
            TimedEffectComponent       = new TimedEffectComponent();
            EnslaveComponent           = new EnslaveComponent();
            CloakComponent             = new CloakComponent();
            #endregion

            base.Initialize();
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory = new AggregateFactory(this);
            WeaponFactory = new WeaponFactory(this);
            DoorFactory = new DoorFactory(this);
            RoomFactory = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory = new WallFactory(this);
            EnemyFactory = new EnemyFactory(this);

            // Initialize Components
            PlayerComponent = new PlayerComponent();
            LocalComponent = new LocalComponent();
            RemoteComponent = new RemoteComponent();
            PositionComponent = new PositionComponent();
            MovementComponent = new MovementComponent();
            MovementSpriteComponent = new MovementSpriteComponent();
            SpriteComponent = new SpriteComponent();
            DoorComponent = new DoorComponent();
            RoomComponent = new RoomComponent();
            HUDSpriteComponent = new HUDSpriteComponent();
            HUDComponent = new HUDComponent();
            InventoryComponent = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent = new EquipmentComponent();
            WeaponComponent = new WeaponComponent();
            BulletComponent = new BulletComponent();
            PlayerInfoComponent = new PlayerInfoComponent();
            WeaponSpriteComponent = new WeaponSpriteComponent();
            StatsComponent = new StatsComponent();
            EnemyAIComponent = new EnemyAIComponent();
            CollectibleComponent = new CollectibleComponent();
            CollisionComponent = new CollisionComponent();
            TriggerComponent = new TriggerComponent();
            EnemyComponent = new EnemyComponent();
            QuestComponent = new QuestComponent();
            LevelManager = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();

            //TurretComponent = new TurretComponent();
            //TrapComponent = new TrapComponent();
            //PortableShopComponent = new PortableShopComponent();
            //PortableShieldComponent = new PortableShieldComponent();
            //MotivateComponent =  new MotivateComponent();
            //FallbackComponent = new FallbackComponent();
            //ChargeComponent = new ChargeComponent();
            //HealingStationComponent = new HealingStationComponent();
            //ExplodingDroidComponent = new ExplodingDroidComponent();

            base.Initialize();
        }
Esempio n. 19
0
        private void LoadWindows()
        {
            Rectangle      screenRectangle = gameRef.ScreenRectangle;
            ContentManager content         = Game.Content;
            SpriteFont     font            = content.Load <SpriteFont>(@"Fonts\ItemDataFont");

            notifications          = NotificationPopup.GetInstance();
            notifications.Font     = font;
            notifications.Size     = new Vector2(300, 0);
            notifications.Position = new Vector2((screenRectangle.Width - notifications.Size.X) / 2, screenRectangle.Height * (3f / 4f));

            Texture2D tooltipBackground = content.Load <Texture2D>(@"GUI\Inventory\Tooltip\background-v2");
            Texture2D tooltipBorder     = content.Load <Texture2D>(@"GUI\Inventory\Tooltip\border-v6");

            SimpleHUDWindow    pauseWindow = new SimpleHUDWindow(font);
            PauseGameComponent pauseMenu   = new PauseGameComponent(font, gameRef.Content);

            pauseMenu.RegisterExitButtonEvent(new EventHandler(CloseWindow));
            pauseMenu.RegisterResumeButtonEvent(new EventHandler(ClosePauseMenuWindow));
            pauseMenu.RegisterCommand(Keys.Escape, ClosePauseMenuWindow, ClickState.RELEASED);
            //pauseMenu.BackgroundTexture = tooltipBackground;

            //TODO: hardcoded offset
            pauseMenu.ButtonOffset    = new Vector2(100, 50);
            pauseWindow.BorderTexture = tooltipBorder;
            //TODO: hardcoded size
            pauseWindow.Size = new Vector2(400, 400);

            Vector2 position = new Vector2((screenRectangle.Width - pauseWindow.Size.X) / 2, (screenRectangle.Height - pauseWindow.Size.Y) / 2);

            pauseWindow.Position  = position;
            pauseWindow.Component = pauseMenu;
            hudManager.Put(Window.PAUSE, pauseWindow);

            InventoryHUDWindow inventoryEquipmentWindow = new InventoryHUDWindow(this, font, gameRef.Content, tooltipBorder, screenRectangle);

            ItemPickedUp += inventoryEquipmentWindow.OnItemPickup;

            hudManager.Put(Window.INVENTORY, inventoryEquipmentWindow);
            commandManager.RegisterCommand(Keys.I, inventoryEquipmentWindow.ShowEquipment);
            commandManager.RegisterCommand(Keys.U, inventoryEquipmentWindow.ShowInventory);
            inventoryEquipmentWindow.RegisterCommand(Keys.I, inventoryEquipmentWindow.ToggleEquipment);
            inventoryEquipmentWindow.RegisterCommand(Keys.U, inventoryEquipmentWindow.ToggleInventory);
            inventoryEquipmentWindow.RegisterCommand(Keys.Escape, inventoryEquipmentWindow.Close);
            inventoryEquipmentWindow.RegisterStatChangeEvent(ChangePlayerStats);

            SimpleHUDWindow     missionLogWindow    = new SimpleHUDWindow(font);
            MissionLogComponent missionLogComponent = new MissionLogComponent(font, gameRef.Content);

            //TODO: hardcoded position and size
            missionLogWindow.Size = new Vector2(800, 600);

            position = new Vector2((screenRectangle.Width - missionLogWindow.Size.X) / 2, (screenRectangle.Height - missionLogWindow.Size.Y) / 2);

            missionLogWindow.Position      = position;
            missionLogWindow.Component     = missionLogComponent;
            missionLogWindow.BorderTexture = tooltipBorder;
            //TODO: hardcoded title
            missionLogWindow.Title = "Mission Log";
            missionLogComponent.RegisterCommand(Keys.L, CloseMissionLogWindow, ClickState.RELEASED);
            missionLogComponent.RegisterCommand(Keys.Escape, CloseMissionLogWindow, ClickState.RELEASED);
            hudManager.Put(Window.MISSION_LOG, missionLogWindow);

            SimpleHUDWindow     playerInfoWindow    = new SimpleHUDWindow(font);
            PlayerInfoComponent playerInfoComponent = new PlayerInfoComponent(font, content, player);

            //TODO: hardcoded size and test position
            playerInfoWindow.Size = new Vector2(400, 300);

            position = new Vector2((screenRectangle.Width - playerInfoWindow.Size.X) / 2, (screenRectangle.Height - playerInfoWindow.Size.Y) / 2);

            playerInfoWindow.Position      = position;
            playerInfoWindow.Component     = playerInfoComponent;
            playerInfoWindow.BorderTexture = tooltipBorder;
            //TODO: hardcoded title
            playerInfoWindow.Title = "Player Stats";
            playerInfoComponent.RegisterCommand(Keys.C, ClosePlayerInfoWindow, ClickState.RELEASED);
            playerInfoComponent.RegisterCommand(Keys.Escape, ClosePlayerInfoWindow, ClickState.RELEASED);
            hudManager.Put(Window.PLAYER_INFO, playerInfoWindow);

            gameInterface = new GameInterface(player, font);
            //TODO: hardcoded position
            gameInterface.Position = new Vector2(screenRectangle.Width - 200, screenRectangle.Height - 60);
        }
Esempio n. 20
0
        /// <summary>
        /// Updates weapons currently in the game.
        /// </summary>
        /// <param name="elapsedTime"></param>
        public void Update(float elapsedTime)
        {
            _playerInfoComponent = _game.PlayerInfoComponent;
            _timer += elapsedTime;
            bool      spriteRemoved = false;
            Equipment equipment;
            Weapon    weapon;
            bool      attacking;
            bool      collisionCreated;


            foreach (Player player in _game.PlayerComponent.All)
            {
                equipment        = _equipmentComponent[player.EntityID];
                attacking        = _playerInfoComponent[player.EntityID].State == PlayerState.Attacking;
                weapon           = _weaponComponent[equipment.WeaponID];
                collisionCreated = _collisionComponent.Contains(equipment.WeaponID);

                //Handle sprites
                if (_weaponSpriteComponent.Contains(player.EntityID))
                {
                    //If the player has a weapon sprite update it
                    spriteRemoved = UpdateWeaponSprite(_weaponSpriteComponent[player.EntityID]);
                }
                else if (attacking)
                {
                    //Otherwise create a new sprite and sound.
                    _game.WeaponFactory.CreateWeaponSprite(equipment.WeaponID, equipment.EntityID);
                    PlayWeaponSound(equipment.WeaponID);
                }

                //Handle more weapon logic.
                if (attacking)
                {
                    if (weapon.AttackType == WeaponAttackType.Ranged)
                    {
                        _bulletTimer += elapsedTime;
                        if (_bulletTimer >= weapon.Speed)
                        {
                            CreateBulletAndSprite(equipment.EntityID, equipment.WeaponID);
                            _bulletTimer = 0;
                        }
                    }
                    else
                    {
                        if (collisionCreated)
                        {
                            UpdateWeaponCollision(equipment.EntityID, equipment.WeaponID);
                        }
                        else
                        {
                            CreateWeaponCollision(equipment.EntityID, equipment.WeaponID);
                        }
                    }
                }
                else if (collisionCreated) //Not attacking but the collision box is there.
                {
                    _collisionComponent.Remove(equipment.WeaponID);
                }
            }
        }