示例#1
0
    public CGameRootCfg(DInitialSysDelegate initialSysDelegate, CGameState root)
    {
        mInitialDelegate = initialSysDelegate;
        mRoot            = root;
        List <CGameState> parentList = new List <CGameState>();

        mStateMap.Clear();
        mStateMap.Add(EStateType.None, new CGameState[] { });
        BuildStateMap(mRoot, parentList);
    }
示例#2
0
    public void setState(CGameState aState)
    {
        if (mState != null)
        {
            mState.destroy();
            mState = null;
        }

        mState = aState;
        mState.init();
    }
示例#3
0
 public void destroy()
 {
     CMouse.destroy();
     CKeyboard.destroy();
     if (mState != null)
     {
         mState.destroy();
         mState = null;
     }
     mInstance = null;
 }
示例#4
0
 public void destroy()
 {
     CMouse.destroy();
     CurrentStageData.destroy();
     //CSpriteManager.destroy();
     if (mState != null)
     {
         mState.destroy();
         mState = null;
     }
     mInstance = null;
 }
示例#5
0
    public void setState(CGameState aState)
    {
        if (mState != null)
        {
            mState.destroy();
            mState = null;
        }

        mState = aState;
        Debug.Log("holi");
        mState.init();
    }
示例#6
0
    private void BuildStateMap(CGameState state, List <CGameState> parentList)
    {
        if (mStateMap.ContainsKey(state.mStateType))
        {
            throw new Exception();
        }

        parentList.Add(state);
        mStateMap.Add(state.mStateType, parentList.ToArray());
        if (state.mChildState != null)
        {
            for (int i = 0; i < state.mChildState.Length; ++i)
            {
                BuildStateMap(state.mChildState[i], parentList);
            }
        }

        parentList.RemoveAt(parentList.Count - 1);
    }
示例#7
0
    private void BuildStateMap(CGameState state, List <CGameState> parentList)
    {
        if (mStateMap.ContainsKey(state.mStateType))
        {
            throw new System.Exception();
        }

        parentList.Add(state);
        mStateMap.Add(state.mStateType, parentList.ToArray());

        if (state.mChildStates != null)
        {
            foreach (CGameState childState in state.mChildStates)
            {
                BuildStateMap(childState, parentList);
            }
        }

        parentList.RemoveAt(parentList.Count - 1);
    }
    private void BuildStateMap(CGameState state, List <CGameState> parentList)
    {
        if (mStateMap.ContainsKey(state.mStateType))
        {
            Debug.LogError(string.Format("same state already defined {0}", state.mStateType));
            throw new System.Exception();
        }

        parentList.Add(state);

        mStateMap.Add(state.mStateType, parentList.ToArray());

        if (state.mChildState != null)
        {
            foreach (CGameState childState in state.mChildState)
            {
                BuildStateMap(childState, parentList);
            }
        }

        parentList.RemoveAt(parentList.Count - 1);
    }
示例#9
0
        public bool AddUci(string[] moves)
        {
            bool update = true;
            int  count  = moves.Length;

            Chess.SetFen();
            if (!Chess.MakeMoves(moves))
            {
                return(false);
            }
            CGameState gs = Chess.GetGameState();

            Chess.SetFen();
            for (int n = 0; n < moves.Length; n++)
            {
                string m = moves[n];
                Chess.MakeMove(m, out _);
                CRec rec = new CRec();
                rec.hash = GetHash();
                if (gs == CGameState.mate)
                {
                    int mate = GetMate(n, count);
                    rec.mat = MateToMat(mate);
                    if (mate > 0)
                    {
                        recList.AddRec(rec);
                    }
                    else if (update)
                    {
                        update = recList.RecUpdate(rec);
                    }
                }
                else
                {
                    recList.AddHash(rec);
                }
            }
            return(true);
        }
示例#10
0
        /* Constructors for the OuterSpace Form. */
        public OuterSpace()
        {
            InitializeComponent();

            // Initialize game managers
            theRaceMgr = new RaceMgr();
            theWindowMgr = new WindowMgr();
            // The crew manager is initialized AFTER the race manager since crews require races
            theCrewMgr = new CrewMgr();
            theGameState = new CGameState();

            // Initialize the title screen and game options
            MainTitle = new CTitleScreen();

            // Get the screen resolution to use
            clientArea.Width = MainTitle.options.GetScreenWidth();
            clientArea.Height = MainTitle.options.GetScreenHeight();

            // Make the title screen draw first
            if (theGameState.IsGameInState(GameStates.MainTitle))
                MainTitle.SetState(0);

            // Set the window size or screen resolution
            this.ClientSize = new Size(clientArea.Width, clientArea.Height);

            // Window or Full Screen mode?
            if (OuterSpace.IsWindowMode == true)
                this.FormBorderStyle = FormBorderStyle.FixedToolWindow;

            starport = new CStarPort();

            // load the galaxy file the user selects.
            theVerse = new Universe();

            // *** THE FOLLOWING IS COMMENTED OUT BUT SHOULD REMAIN FOR FUTURE REFERENCE UNTIL DEAMED UNECESSARY ***
            //
            //Dim aRace As Race = theRaceMgr.GetRace("Vulcan")
            //Dim crew(4) As CrewMember
            //crew(0) = New CrewMember(theCrewMgr.GetNextKey(), 1, "John Smith", 50, 50, 50, 50, 50, 0)
            //theCrewMgr.HireCrewMember(crew(0))
            //crew(1) = New CrewMember(theCrewMgr.GetNextKey(), 2, "Pon Far", 50, 50, 50, 50, 50, 0)
            //theCrewMgr.HireCrewMember(crew(1))
            //crew(2) = New CrewMember(theCrewMgr.GetNextKey(), 3, "Rommy", 50, 50, 50, 50, 50, 0)
            //theCrewMgr.HireCrewMember(crew(2))
            //crew(3) = New CrewMember(theCrewMgr.GetNextKey(), 4, "Worf", 50, 50, 50, 50, 50, 0)
            //theCrewMgr.HireCrewMember(crew(3))

            //theCrewMgr.Train(1, 4, 3)
            //theCrewMgr.Train(1, 3, 10)
            //theCrewMgr.Train(2, 0, 3)
            //theCrewMgr.Train(3, 2, 3)
            //theCrewMgr.Train(4, 1, 3)

            msgbox = new Messages();
            playership = new vehicleStats();
            TV = new vehicleStats();
            debugfile = new DebugOutput(debugdir + "Debug-Out.txt");

            // Set the parameters of the Terrian Vehicle.
            TV.stellerSpeed = 0.03f;
            TV.systemSpeed = 0.03f;
            TV.combatSpeed = 0.03f;
            TV.thetadif = 1;
            TV.yawdif = 1;

            // Setup other ships
            for (int i = 0; i < MAXOTHERSHIPS; i++)
            {
                otherships[i] = new vehicleStats();
                otherships[i].shipName = null;
            }

            // Set up a refrence table for costly trigometric function caclulations.
            for (int i = 0; i < 360; i++)
            {
                TanRef[i] = (float)Math.Tan(i * (Math.PI / 180));
                moveX[i] = (float)Math.Cos(i * (Math.PI / 180));
                moveY[i] = (float)Math.Sin(i * (Math.PI / 180));
            }

            TanRef[0] = 0.0f;
            moveX[0] = 1.0f;
            moveY[0] = 0.0f;
            TanRef[180] = 0.0f;
            moveX[180] = -1.0f;
            moveY[180] = 0.0f;
            TanRef[90] = (float)Math.Tan(90.1 * (Math.PI / 180));
            moveX[90] = 0.0f;
            moveY[90] = 1.0f;
            TanRef[270] = (float)Math.Tan(270.1 * (Math.PI / 180));
            moveX[270] = 0.0f;
            moveY[270] = -1.0f;
            moveX[360] = 1.0f;
            moveY[360] = 0.0f;

            // Set up initial game clock
            theGameClock = new CGameClock(2317, 3, 2, 0);

            // Windows.Forms.Cursor.Hide()
            this.Cursor.Dispose();

            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
        }
示例#11
0
        /// <summary>
        /// Uci MOve TO SAN move
        /// </summary>

        public string UmoToSan(string umo)
        {
            if (!MakeMove(umo, out int emo))
            {
                return(String.Empty);
            }
            CGameState gs = GetGameState(out bool check);

            UnmakeMove(emo);
            string[] arrPiece = { "", "", "N", "B", "R", "Q", "K" };
            int      fr       = emo & 0xff;
            int      to       = (emo >> 8) & 0xff;
            int      flags    = emo & 0xff0000;
            int      pieceFr  = g_board[fr] & 7;
            int      pieceTo  = g_board[to] & 7;
            bool     isAttack = (pieceTo > 0) || ((flags & moveflagPassing) > 0);

            if ((flags & moveflagCastleKing) > 0)
            {
                return("O-O");
            }
            if ((flags & moveflagCastleQueen) > 0)
            {
                return("O-O-O");
            }
            List <int> moves   = GenerateValidMoves(out _);
            bool       uniRank = true;
            bool       uniFile = true;

            foreach (int m in moves)
            {
                int f = m & 0xff;
                if (f != fr)
                {
                    int piece = g_board[f] & 7;
                    if ((piece == pieceFr) && ((m & 0xff00) == (emo & 0xff00)))
                    {
                        if ((m & 0xf0) != (emo & 0xf0))
                        {
                            uniRank = false;
                        }
                        if ((m & 0xf) != (emo & 0xf))
                        {
                            uniFile = false;
                        }
                    }
                }
            }
            if (isAttack && (pieceFr == piecePawn))
            {
                uniFile = false;
            }
            string faf    = uniFile ? "" : umo.Substring(0, 1);
            string far    = uniRank ? "" : umo.Substring(1, 1);
            string fb     = umo.Substring(2, 2);
            string attack = isAttack ? "x" : "";
            string promo  = "";

            if ((flags & moveflagPromoteKnight) > 0)
            {
                promo = "=N";
            }
            if ((flags & moveflagPromoteBishop) > 0)
            {
                promo = "=B";
            }
            if ((flags & moveflagPromoteRook) > 0)
            {
                promo = "=R";
            }
            if ((flags & moveflagPromoteQueen) > 0)
            {
                promo = "=Q";
            }
            string fin = check ? "+" : "";

            if (gs == CGameState.mate)
            {
                fin = "#";
            }
            return($"{arrPiece[pieceFr]}{faf}{far}{attack}{fb}{promo}{fin}");
        }
示例#12
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            _fire_bullet_time += gameTime.ElapsedGameTime.TotalMilliseconds;
            int Highscore = 0;

            var ks = Keyboard.GetState();
            var ms = Mouse.GetState();

hack:
            switch (_state)
            {
            case CGameState.MainScreen:
                var ret = _mainscreen.Update(ms);
                if (ret.HasValue && (ret.Value == CGameState.Quit || ret.Value == CGameState.StartGame || ret.Value == CGameState.CreditsScreen))
                {
                    _state = ret.Value;
                    goto hack;
                }
                break;

            case CGameState.CreditsScreen:
                if (_creditsScreen == null)
                {
                    LoadCreditsScreen();
                }

                ret = _creditsScreen.Update(ms);
                if (ret.HasValue && ret.Value == CGameState.MainScreen)
                {
                    _state = ret.Value;
                    goto hack;
                }
                break;

            case CGameState.StartGame:
                LoadGame();
                break;

            case CGameState.Playing:
                if (ms.LeftButton == ButtonState.Pressed && _fire_bullet_time > 180)
                {
                    _bullet_manager.Add(_player.GetPosition(), _player.GetDirection());
                    _fire_bullet_time = 0;
                }

                _player.Update(ks, ms);
                _background_manager.Update(_wave_manager.WaveCount, _wave_manager.Highscore);
                _bullet_manager.Update();
                _bullet_hits_enemy.Update();
                _portal_manager.Update();
                _energy_storage_manager.Update();
                _powerup_manager.Update(gameTime, ref _player, ref _energy_storage_manager);
                _enemy_managers.Values
                .ToList()
                .ForEach(x => x.Update(ref Highscore, gameTime));
                _wave_manager.Update(gameTime, ref Highscore);
                //game over
                if (_energy_storage_manager._energy_storages.Count == 0)
                {
                    _state = CGameState.Gameover;
                    goto hack;
                }
                break;

            case CGameState.Gameover:
                if (_gameoverscreen == null)
                {
                    LoadGameOver(_wave_manager.Highscore);
                }
                ret = _gameoverscreen.Update(ms);
                if (ret.HasValue && ret.Value == CGameState.StartGame)
                {
                    _state = ret.Value;
                    goto hack;
                }
                else if (ret.HasValue && ret.Value == CGameState.Quit)
                {
                    _state = ret.Value;
                    goto hack;
                }
                break;

            case CGameState.Quit:
                Exit();
                break;
            }

            if (ks.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            base.Update(gameTime);
        }
示例#13
0
        public void LoadGame()
        {
            _enemy_managers.Clear();
            _gameoverscreen         = null;
            _hp50_root              = null;
            _hp250_root             = null;
            _bullet_manager         = null;
            _player                 = null;
            _bullet_hits_enemy      = null;
            _energy_storage_manager = null;
            _portal_manager         = null;
            _wave_manager           = null;
            _background_manager     = null;
            _powerup_manager        = null;

            #region HealthBar LoadContent
            _hp50_root = new HealthBar(
                _tstorage["hp_50"],
                50,
                4
                );

            _hp250_root = new HealthBar(
                _tstorage["hp_250"],
                250,
                6
                );
            #endregion

            #region BackgroundManager LoadContent
            _background_manager = new BackgroundManager
                                  (
                _fstorage["hs_wave"],
                new Vector2(1680, 72),
                new Vector2(1770, 23)
                                  );

            _background_manager.AddTexture
            (
                _tstorage["map"],
                new Vector2(0, 0)
            );
            _background_manager.AddTexture
            (
                _tstorage["highscore_wave"],
                new Vector2(WIDTH - 360, 0)
            );
            _background_manager.AddTexture
            (
                _tstorage["left_energy_hp"],
                new Vector2(WIDTH / 4, 0)
            );
            _background_manager.AddTexture
            (
                _tstorage["right_energy_hp"],
                new Vector2(WIDTH / 4 * 2, 0)
            );
            #endregion

            #region MainScreen PortalManager
            List <Vector2> portal_location = new List <Vector2>()
            {
                new Vector2(700, 60),
                new Vector2(1750, 300),
                new Vector2(80, 850),
                new Vector2(750, 850)
            };

            _portal_manager = new PortalManager(
                _tstorage["portal_vecji"],
                133,
                150
                );

            foreach (var a in portal_location)
            {
                _portal_manager.AddPortal(a);
            }
            #endregion

            #region EnergyStorageManager LoadContent
            _energy_storage_manager = new EnergyStorageManager(
                _tstorage["energy_point"],
                214,
                200,
                _hp250_root
                );

            _energy_storage_manager.Add
            (
                new Vector2(250, 300),
                new Vector2((WIDTH / 4) + 35, 40),
                2000
            );

            _energy_storage_manager.Add
            (
                new Vector2(1000, 500),
                new Vector2((WIDTH / 4 * 2) + 35, 40),
                2000
            );
            #endregion

            #region EnemyManager LoadContent
            _enemy_managers.Add("enemy1", new EnemyManager(
                                    ref _portal_manager,
                                    ref _energy_storage_manager,
                                    _tstorage["enemy_1"],
                                    _hp50_root, 48, 50, 30, 150, 7, 4
                                    ));

            _enemy_managers.Add("enemy2", new EnemyManager(
                                    ref _portal_manager,
                                    ref _energy_storage_manager,
                                    _tstorage["enemy_2"],
                                    _hp50_root, 50, 50, 30, 200, 8, 5
                                    ));

            _enemy_managers.Add("enemy3", new EnemyManager(
                                    ref _portal_manager,
                                    ref _energy_storage_manager,
                                    _tstorage["enemy_3"],
                                    _hp50_root, 104, 110, 30, 500, 2, 2
                                    ));

            _enemy_managers.Add("enemy4", new EnemyManager(
                                    ref _portal_manager,
                                    ref _energy_storage_manager,
                                    _tstorage["enemy_4"],
                                    _hp50_root, 55, 100, 30, 300, 8, 5
                                    ));
            #endregion

            #region BulletManager LoadContent
            _bullet_manager = new BulletManager(
                _tstorage["okrogel_metek6"],
                win_size
                );
            #endregion

            #region Player LoadContent
            _player = new Player(
                _tstorage["player"],
                win_size,
                new Vector2(700, 500),
                60,
                50,
                40
                );
            #endregion

            #region BulletHitsEnemy LoadContent
            _bullet_hits_enemy = new BulletHitsEnemy(
                ref _enemy_managers,
                ref _bullet_manager,
                ref _player,
                _fstorage["DamageFont"],
                _tstorage["mini_explosion"]
                );
            #endregion

            #region WaveManager LoadContent
            _wave_manager = new WaveManager(ref _enemy_managers, 5000, 1000);
            #endregion

            #region PowerupManager LoadContent
            List <Rectangle> spawn_locs = new List <Rectangle>()
            {
                new Rectangle(100, 100, 250, 150),
                new Rectangle(100, 600, 800, 200),
                new Rectangle(900, 200, 600, 250),
                new Rectangle(1300, 700, 400, 200)
            };

            _powerup_manager = new PowerupManager(10000, spawn_locs);
            _powerup_manager.AddPowerup
            (
                _tstorage["damage_pu"],
                34,
                50,
                10,
                PowerupManager.PowerUpType.PUT_PWR
            );
            _powerup_manager.AddPowerup
            (
                _tstorage["health_pu"],
                35,
                50,
                8,
                PowerupManager.PowerUpType.PUT_HP
            );
            #endregion

            _state = CGameState.Playing;
        }
示例#14
0
 internal static HandleRef getCPtr(CGameState obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
示例#15
0
 public void AddGameState(CGameState GameState)
 {
     testPINVOKE.CGame_AddGameState(swigCPtr, CGameState.getCPtr(GameState));
 }