public AbstractInputMgr(ActionBarMgr actionBarMgr, SceneMgr sceneMgr)
        {
            this.actionBarMgr = actionBarMgr;
            this.sceneMgr     = sceneMgr;

            sceneMgr.AddMouseListener(this);
            sceneMgr.AddKeyListener(this);
        }
        /// <summary>
        /// vytvori hraci action bar, input manager a zbrane a bazi nebo mining module
        /// </summary>
        /// <param name="p">hrac kteremu se maji vytvorit objekty</param>
        private void CreateActiveObjectsOfPlayer(Player p)
        {
            if (p.IsActivePlayer())
            {
                p.CreateWeapons();

                p.Baze = SceneObjectFactory.CreateBase(this, p);

                BaseIntegrityBar ellipse = SceneObjectFactory.CreateBaseIntegrityBar(this, p);

                HpBarControl control = new HpBarControl(ellipse);
                p.Baze.AddControl(control);

                DelayedAttachToScene(ellipse);
                DelayedAttachToScene(p.Baze);
            }
            else
            {
                if (p.Device == null)
                {
                    MiningModule obj = SceneObjectFactory.CreateMiningModule(this, p.Data.MiningModuleStartPos, p);
                    DelayedAttachToScene(obj);
                    DelayedAttachToScene(SceneObjectFactory.CreateMiningModuleIntegrityBar(this, obj, p));

                    p.Device = obj;
                }
            }

            if (p.IsCurrentPlayer())
            {
                actionBarMgr = new ActionBarMgr(this);
                StateMgr.AddGameState(actionBarMgr);

                if (p.IsActivePlayer())
                {
                    inputMgr = new PlayerInputMgr(p, this, actionBarMgr);
                    actionBarMgr.CreateActionBarItems(p.GetActions <IPlayerAction>(), false);
                    InitAutomaticMineLauncher();
                }
                else
                {
                    if (p.Device.HasControlOfType <MiningModuleControl>())
                    {
                        return;
                    }

                    MiningModuleControl mc = new MiningModuleControl();
                    mc.Owner = p;
                    p.Device.AddControl(mc);

                    inputMgr = new SpectatorInputMgr(p, this, p.Device, actionBarMgr);
                    actionBarMgr.CreateActionBarItems(p.GetActions <ISpectatorAction>(), true);
                    SceneObjectFactory.CreateSpectatorActionReadinessIndicators(p);
                }
            }
        }
Exemplo n.º 3
0
        private void LoadActivableActionIfAvailable()
        {
            if (currentWeapon.NextSpecialAction() == null || !(currentWeapon.NextSpecialAction() is ActiveWeapon))
            {
                return;
            }

            ActionBarMgr mgr = SceneMgr.StateMgr.GetGameStateOfType <ActionBarMgr>();

            mgr.SwitchAction(this, currentWeapon.NextSpecialAction());
        }
        public SpectatorInputMgr(Player p, SceneMgr sceneMgr, ISceneObject obj, ActionBarMgr actionMgr) : base(actionMgr, sceneMgr)
        {
            IControledDevice    d  = obj.GetControlOfType <IControledDevice>();
            MiningModuleControl mc = obj.GetControlOfType <MiningModuleControl>();

            if (mc == null)
            {
                throw new Exception("You must initialize SpectatorInputManager with object containig MiningModuleControl");
            }
            if (d == null)
            {
                throw new Exception("You must initialize SpectatorInputManager with object containig IControledDevice control");
            }

            plr           = p;
            device        = d;
            miningControl = mc;
        }
Exemplo n.º 5
0
 public PlayerInputMgr(Player p, SceneMgr sceneMgr, ActionBarMgr actionMgr) : base(actionMgr, sceneMgr)
 {
     plr = p;
 }