상속: MapSpawnGameState
예제 #1
0
        //public void mMouse_Click(string channel, object sender, EventArgs args) { }
        public override void Update()
        {
            MouseState mouse_state = Mouse.GetState(); // Gets the mouse state object
            Point mouse_position = new Point(mouse_state.X, mouse_state.Y); // creates a point for the mouse's position

            if (mouseClicked)
            {
                if (mouse_state.LeftButton == ButtonState.Pressed)
                {
                    //mouseClicked = false;
                    return;
                }
                else if (firstLevel == true)
                {
                    mPlayer1InOverWorld.CurrentNode = "Node1";
                    mPlayer1InOverWorld.SpawnTutorial = true;
                    //mouseClicked = false;
                    MapSpawnGameState new_state;
                    if (mPlayer1InOverWorld.TutorialMode == true)
                    {
                        new_state = new TutorialMapSpawnGameState((new FirstMapFactory()).NewInstance());
                    }
                    else
                    {
                        new_state = new MapSpawnGameState((new FirstMapFactory()).NewInstance());
                    }
                    Mediator.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                }
                else if (secondLevel == true)
                {
                    mPlayer1InOverWorld.CurrentNode = "Node2";
                    mPlayer1InOverWorld.level2Tutorial = true;
                    //mouseClicked = false;
                    MapSpawnGameState new_state;
                    if (mPlayer1InOverWorld.TutorialMode == true)
                    {
                        new_state = new TutorialMapSpawnGameState((new SecondMapFactory()).NewInstance());
                    }
                    else
                    {
                        new_state = new MapSpawnGameState((new SecondMapFactory()).NewInstance());
                    }
                    Mediator.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                }
                else if (thirdLevel == true)
                {
                    mPlayer1InOverWorld.CurrentNode = "Node3";
                    //mouseClicked = false;
                    MapSpawnGameState new_state = new MapSpawnGameState((new ThirdMapFactory()).NewInstance());
                    Mediator.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                }
                else if (shop1 == true)
                {
                    //Programs Available in the shop MIGHT NEED TO CHANGE INSTANTIATION LATER
                    List<ProgramFactory> tempShopList = new List<ProgramFactory>();

                    tempShopList.Add(new SniperFactory());
                    tempShopList.Add(new HackerFactory());
                    tempShopList.Add(new MemManFactory());
                    tempShopList.Add(new TrojanFactory());
                    tempShopList.Add(new Sniper2Factory());

                    //mouseClicked = false;

                    ShopState new_state = new ShopState(tempShopList);
                    Mediator.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                }
                else if (fourthLevel == true)
                {
                    //mouseClicked = false;
                    mPlayer1InOverWorld.CurrentNode = "Node4";
                    MapSpawnGameState new_state = new MapSpawnGameState((new FourthMapFactory()).NewInstance());
                    Mediator.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                }
                else if (fifthLevel == true)
                {
                    //mouseClicked = false;
                    mPlayer1InOverWorld.CurrentNode = "Node5";
                    MapSpawnGameState new_state = new MapSpawnGameState((new FifthMapFactory()).NewInstance());
                    Mediator.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                }
                else if (shop2 == true)
                {
                    List<ProgramFactory> tempShopList = new List<ProgramFactory>();

                    tempShopList.Add(new SniperFactory());
                    tempShopList.Add(new HackerFactory());
                    tempShopList.Add(new Hacker2Factory());
                    tempShopList.Add(new MemManFactory());
                    tempShopList.Add(new TrojanFactory());
                    tempShopList.Add(new Trojan2Factory());
                    tempShopList.Add(new Sniper2Factory());

                    //mouseClicked = false;

                    ShopState new_state = new ShopState(tempShopList);
                    Mediator.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                }
                else if (bossLevel == true)
                {
                    //mouseClicked = false;
                    mPlayer1InOverWorld.CurrentNode = "Node6";
                    MapSpawnGameState new_state = new MapSpawnGameState((new SixthMapFactory()).NewInstance());
                    Mediator.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                }
                else
                {
                    mouseClicked = false;
                    //PushState(new MapSpawnGameState((new SpawnMapFactory()).NewInstance()));
                    //ShopState new_state = new ShopState();
                    //MapSpawnGameState new_state = new MapSpawnGameState((new SpawnMapFactory()).NewInstance());
                    //Mediator.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));
                }
            }

            //if (isExitButtonClicked)
            //{
            //    if (mouse_state.LeftButton == ButtonState.Released)
            //    {
            //        ServerOverworldState new_state = new ServerOverworldState();
            //        Mediator.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));
            //    }
            //}

            for (int i = 0; i < nodeArray.Length; i++)
            {
                if (nodeArray[i].Contains(mouse_position) && mouse_state.LeftButton == ButtonState.Pressed && !mouseClicked && isNodeClickable[i] == true)
                {
                    //Node slection
                    mMouseClickedRectangleIndex = i;
                    //isNodeHacked[i] = true;
                    mouseClicked = true;

                    firstLevel = false;
                    secondLevel = false;
                    thirdLevel = false;
                    fourthLevel = false;
                    fifthLevel = false;
                    bossLevel = false;
                    shop1 = false;
                    shop2 = false;

                    if (i == 0 && mPlayer1InOverWorld.IsNodeHacked("Node1") == false)
                    {
                        firstLevel = true;
                    }
                    else if (i == 1)
                    {
                        shop1 = true;
                    }
                    else if (i == 2)
                    {
                        secondLevel = true;
                    }
                    else if (i == 3)
                    {
                        thirdLevel = true;
                    }
                    else if (i == 4)
                    {
                        fourthLevel = true;
                    }
                    else if (i == 5)
                    {
                        fifthLevel = true;
                    }
                    else if (i == 6)
                    {
                        shop2 = true;
                    }
                    else if (i == 7)
                    {
                        bossLevel = true;
                    }

                    return;
                }
            }
        }
예제 #2
0
        public override void Update()
        {
            MouseState mouse_state = Mouse.GetState(); // Gets the mouse state object
            Point mouse_position = new Point(mouse_state.X, mouse_state.Y); // creates a point for the mouse's position

            if (isContinueButtonClicked)
            {
                if (mouse_state.LeftButton == ButtonState.Released)
                {
                    if (mPlayer1Tutorial.SpawnTutorial == true)
                    {
                        mPlayer1Tutorial.SpawnTutorial = false;
                        TutorialMapSpawnGameState new_state = new TutorialMapSpawnGameState(display_map_state);
                        _mediator_manager.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));
                    }
                    else if (mPlayer1Tutorial.level2Tutorial == true)
                    {
                        mPlayer1Tutorial.level2Tutorial = false;
                        TutorialMapSpawnGameState new_state = new TutorialMapSpawnGameState(display_map_state);
                        _mediator_manager.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));

                    }
                    else
                    {
                        MapPlayGameState new_state = new MapPlayGameState(display_map_state);
                        _mediator_manager.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));
                    }
                }
            }

            //Update for Continue Button
            if (ContinueButtonRect.Contains(mouse_position) && mouse_state.LeftButton == ButtonState.Pressed)
            {
                isContinueButtonClicked = true;
            }
            // if hovering over rectangle
            else if (ContinueButtonRect.Contains(mouse_position))
            {
            }
            else // neither clicking nor hovering over rectangle
            {
                isContinueButtonClicked = false;
            }
        }