//设置名字,并保存 public void setNewPlayer(string name) { if (name.Length != 0 && TextCheck.isUserName(name) && name.Length <= 8) { data.nowId = data.allIdCount++ + 1; PlayerPrefs.SetInt("nowId", data.nowId); PlayerPrefs.SetInt("AllIDCount", data.allIdCount); myNpc.npcName = name; LoadAndSave.saveNpc(myNpc, data.nowId); this.uiCamera.gameObject.SetActive(false); } else if (name.Length == 0) { GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").transform.Find("Placeholder").GetComponent <Text>().text = "名字不能为空"; GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").GetComponent <InputField>().text = ""; } else if (name.Length <= 8) { GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").transform.Find("Placeholder").GetComponent <Text>().text = "名字里不能带字符"; GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").GetComponent <InputField>().text = ""; } else { GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").transform.Find("Placeholder").GetComponent <Text>().text = "名字不能超过8位"; GameObject.Find("Game").transform.Find("UICamera").transform.Find("FistGameCanvas").transform.Find("NameInputField").GetComponent <InputField>().text = ""; } }
public Game1() { currentGameState = GameState.SPLASHSCREEN; graphics = new GraphicsDeviceManager(this); graphics.IsFullScreen = false; Content.RootDirectory = "Content"; graphics.PreferredBackBufferHeight = 1080 - 40 - 20; graphics.PreferredBackBufferWidth = 1920; graphics.ApplyChanges(); Window.AllowUserResizing = true; input.ReadImageSizeDataSheet(); playerSpriteSheets = new Dictionary <string, Texture2D>(); enemySpriteSheets = new Dictionary <string, Texture2D>(); songDictionnary = new Dictionary <string, Song>(); soundEffectDictionnary = new Dictionary <string, SoundEffect>(); levelEditor = new LevelEditor(); cameraOffset = new Vector2(0, 0); texturesDictionary = new Dictionary <string, Texture2D>(); enemyList = new List <Enemy>(); Enums = new Enums(); splashScreen = new SplashScreen(); mainMenu = new MainMenu(); gameMenu = new GameMenu(); credits = new Credits(); itemUIManager = new ItemUIManager(); minimap = new Minimap(); loadAndSave = new LoadAndSave(allGameObjectList, texturesDictionary); //MUSIC turnOnMusic = true; //must be the first instance! audioManager = AudioManager.AudioManagerInstance(); }
private void Awake() { data = GameObject.Find("Stage" + 1).GetComponent <LoadAndSave>(); IsPass = data.m_datainfolist.stageData.Pass; RunTime = data.m_datainfolist.stageData.RunTime; //_instance = this; if (_instance == null) { _instance = this; DontDestroyOnLoad(_instance); } else { myTutorials = GameObject.FindObjectsOfType <MyTutorial>(); for (int i = 0; i < myTutorials.Length; i++) { if (myTutorials[i] != _instance) { Destroy(myTutorials[i].gameObject); } else { DontDestroyOnLoad(_instance); } } } //cameraFollow = GameObject.FindObjectOfType<CameraFollow>(); ShowTutorialProcess = GameObject.Instantiate(Resources.Load <GameObject>("Tutorial/" + "ShowTutorialProcess")); currentProcess = ShowTutorialProcess.transform.GetChild(0).GetChild(0).GetComponentInChildren <Text>(); currentProcess.text = "1"; totalProcess = ShowTutorialProcess.transform.GetChild(0).GetChild(1).GetComponentInChildren <Text>(); totalProcess.text = " / " + totalBool.ToString(); ShowTutorialProcess.SetActive(false); }
private void Awake() { datamanger = GameObject.Find("Stage" + StageNum).GetComponent <LoadAndSave>(); if (!datamanger.m_datainfolist.stageData.Pass) { if (BeeHouse.Count > 0) { for (int i = 0; i < BeeHouse.Count; i++) { GroupEnemyAIStateController m_ai = new GroupEnemyAIStateController(); m_ai.Role = BeeHouse[i].gameObject; m_ai.Intialize(this); groupEnemyAIStateControllers.Add(m_ai); Debug.Log(m_ai.Role.name); } } } else { if (BeeHouse.Count > 0) { for (int i = 0; i < BeeHouse.Count; i++) { GroupEnemyAIStateController m_ai = new GroupEnemyAIStateController(); m_ai.Role = BeeHouse[i].gameObject; m_ai.PassInitialize(this); groupEnemyAIStateControllers.Add(m_ai); Debug.Log(m_ai.Role.name); } } } }
public void Initialized(AIGameManger _aIGameManger, LoadAndSave data) { IsPass = false; //Door = GameObject.FindGameObjectWithTag("StageDoor"); aIGameManger = _aIGameManger; Door = Instantiate(Resources.Load <GameObject>("Door"), StageDoorPos.position, Quaternion.identity); Door.GetComponent <DoorInfo>().NextStage = aIGameManger.StageNum + 1; Door.SetActive(false); stageData = data; particileControl = GetComponent <ParticileControl>(); }
private void LoadNewGame(LoadAndSave loadAndSave) { ItemUIManager.armorPickedUp = false; ItemUIManager.snailShellPickedUp = false; ItemUIManager.shovelPickedUp = false; ItemUIManager.scissorsPickedUp = false; ItemUIManager.goldenUmbrellaPickedUp = false; ItemUIManager.healthPickedUp = false; ItemUIManager.powerPickedUp = false; ItemUIManager.jumpPickedUp = false; ItemUIManager.cornnencyQuantity = 0; Game1.wormPlayer.gameObjectPosition = new Vector2(13444, 1700); }
private IEnumerator DelayedLoadLevel(string levelString, LoadAndSave _saveGame) { yield return(new WaitForSeconds(1.1f)); //Application.LoadLevel(levelString); if (levelString == "MainScene") { GameManager.Instance.LoadAllLaws(); GameManager.Instance.StartGameSession(_saveGame); } SceneManager.LoadScene(levelString); PlayMusicOnLoad(levelString); }
private void ReevaluateSaveState() { IXmlDocument disk = LoadAndSave.Load(); if (XNode.DeepEquals(XDocument.Parse(disk.OuterXml), XDocument.Parse(ConfigXml.OuterXml))) { SaveState = SaveState.Saved; } else { SaveState = SaveState.Changed; } }
public void StartGameSession(LoadAndSave _savedGame) { m_currentGameState = GameState.GameState_BEGINSEMESTER; AddInitialLaws(); if (_savedGame != null) { loadGame(_savedGame); } else { InitNewGame(); RefreshJauge(); m_currentLaw = m_currentGameSessionLaws.ElementAt(UnityEngine.Random.Range(0, m_currentGameSessionLaws.Count)); } }
public void init() { int nowId = PlayerPrefs.GetInt("nowId"); if (nowId != 0) { if (LoadAndSave.loadNpc(this.npc, nowId) == 0) { mainGame.firstBegin(); } } else { mainGame.firstBegin(); } }
private void loadGame(LoadAndSave loadAndSave) { this.m_governmentOpinion = loadAndSave.GovernementOpinion; this.m_populaceOpinion = loadAndSave.PopulaceOpinion; this.m_personalMoney = loadAndSave.MoneyValue; this.m_economy = loadAndSave.EconomyValue; this.m_employement = loadAndSave.EmploymentValue; this.m_religion = loadAndSave.ReligionValue; foreach (int id in loadAndSave.ListCurrentLawId) { this.m_currentGameSessionLaws.AddLast(this.FindLawById(id)); } this.m_currentLaw = this.FindLawById(loadAndSave.CurrentLawId); this.m_currentMonthInSemester = loadAndSave.CurrentMonthInSemester; }
public override void OnInspectorGUI() { LoadAndSave saveInfo = (LoadAndSave)target; DrawDefaultInspector(); //EditorGUILayout.LabelField("castle", saveInfo._Castle.ToString()); //this.Repaint(); GUILayout.BeginHorizontal(); if (GUILayout.Button("saveResources")) { saveInfo.SaveCities(); } if (GUILayout.Button("loadResources")) { saveInfo.LoadCities(); } GUILayout.EndHorizontal(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load <SpriteFont>("Fonts/LuckiestGuy"); LoadAndSave loading = new LoadAndSave(allGameObjectList, texturesDictionary); //MUSIC audioManager.LoadSongsAndSound(this.Content); loading.loadEverything(this.Content, ref playerSpriteSheets, ref texturesDictionary, ref enemySpriteSheets); levelEditor.loadTextures(Content, ref texturesDictionary, graphics.GraphicsDevice); animManager = new AnimationManager(playerSpriteSheets); wormPlayer = new Player(playerSpriteSheets["playerMoveSpriteSheet"], new Vector2(SpriteSheetSizes.spritesSizes["Reggie_Move_X"] / 5, SpriteSheetSizes.spritesSizes["Reggie_Move_Y"] / 5), new Vector2(13444, 1500), (int)Enums.ObjectsID.PLAYER); //SHOP shopKeeper = new ShopKeeper(texturesDictionary["cornnency"], new Vector2(334, 407), new Vector2(2600, 4225), (int)Enums.ObjectsID.SHOPKEEPER, texturesDictionary); //13494 enemySpawnList = new List <Platform>(); allGameObjectList = new List <GameObject>(); interactiveObject = new List <GameObject>(); cornnencyList = new List <GameObject>(); levelObjectList = new List <GameObject>(); loadAndSave.LoadGameObjects(ref allGameObjectList, ref wormPlayer); //allGameObjectList.Add(shopKeeper); levelManager = new Levels(ref wormPlayer.gameObjectPosition, ref levelObjectList, ref allGameObjectList); levelManager.sortGameObjects(); loadAndSave = new LoadAndSave(allGameObjectList, texturesDictionary); ingameMenus = new IngameMenus(spriteBatch, texturesDictionary, playerSpriteSheets); FillLists(); // MONO: use this.Content to load your game content here hakume = new Boss(null, new Vector2(400, 422), new Vector2(-4750, -11450), (int)Enums.ObjectsID.BOSS, enemySpriteSheets); hakume.SetPlayer(wormPlayer); }
public void Update(Game1 Game, LoadAndSave loadAndSave) { if ((Keyboard.GetState().IsKeyDown(Keys.W) || Keyboard.GetState().IsKeyDown(Keys.Up) || GamePad.GetState(0).IsButtonDown(Buttons.DPadUp) || GamePad.GetState(0).ThumbSticks.Left.Y > 0.5f) && !buttonPressed) { currentButton--; if (currentButton < 0) { currentButton = Enums.GameMenuButtons.MAINMENU; } buttonPressed = true; } if ((Keyboard.GetState().IsKeyDown(Keys.S) || Keyboard.GetState().IsKeyDown(Keys.Down) || GamePad.GetState(0).IsButtonDown(Buttons.DPadDown) || GamePad.GetState(0).ThumbSticks.Left.Y < -0.5f) && !buttonPressed) { currentButton++; if (currentButton > Enums.GameMenuButtons.MAINMENU) { currentButton = Enums.GameMenuButtons.RESUME; } buttonPressed = true; } if ((Keyboard.GetState().IsKeyDown(Keys.Enter) || GamePad.GetState(0).IsButtonDown(Buttons.A)) && !buttonPressed) { buttonPressed = true; switch (currentButton) { case Enums.GameMenuButtons.RESUME: Game1.currentGameState = Game1.GameState.GAMELOOP; break; case Enums.GameMenuButtons.OPTIONS: break; case Enums.GameMenuButtons.MAINMENU: Game1.currentGameState = Game1.GameState.MAINMENU; break; } } if (Keyboard.GetState().GetPressedKeys().Count() == 0 && GamePad.GetState(0).ThumbSticks.Left.Y < 0.5f && GamePad.GetState(0).ThumbSticks.Left.Y > -0.5f && GamePad.GetState(0).IsButtonUp(Buttons.DPadUp) && GamePad.GetState(0).IsButtonUp(Buttons.DPadDown) && GamePad.GetState(0).IsButtonUp(Buttons.A)) { buttonPressed = false; } }
public void loadGameFile() { try { LoadAndSave loadAndSave = XmlSerializerHelper <LoadAndSave> .DeserializeXmlFile(Application.streamingAssetsPath + "/PlayerSave.xml"); LevelManager.Instance.LoadLevel("MainScene", loadAndSave); } catch (Exception e) { // Trigger a breakpoint if Visual is attached to UNITY #if UNITY_EDITOR if (Debugger.IsAttached) { Debugger.Break(); } #endif UnityEngine.Debug.Log(e.Message); } }
public void PassInitialized(AIGameManger _aIGameManger, LoadAndSave data) { IsPass = true; //BoxBackageUIControl.Instance.SuccessState(); aIGameManger = _aIGameManger; Door = Instantiate(Resources.Load <GameObject>("Door"), StageDoorPos.position, Quaternion.identity); Door.GetComponent <DoorInfo>().NextStage = aIGameManger.StageNum + 1; Vector3 ChallangePos = this.transform.position; Syringe = GameObject.Instantiate(Resources.Load <GameObject>("Syringe"), ChallangePos, Quaternion.identity); medicine = Syringe.transform.GetChild(3).gameObject; medicine.transform.localScale = new Vector3(1, .1f, 1); //Syringe.SetActive(true); stageData = data; particileControl = GetComponent <ParticileControl>(); if (PlaceObj != null) { PlaceObj.SetActive(true); } //StartCoroutine(PassSpawner()); }
public void Initialized(LoadAndSave _data, Transform _Player) { Data = _data; Data.CreatHoleModel(this); Data.CreatTreeModel(this); Player = _Player; foreach (MaoTreeControl tree in MaoTree) { tree.Player = Player.gameObject; } foreach (HoleControl hole in MaoHole) { hole.Player = Player.gameObject; if (hole.IsOn) { hole.tree.Player = Player.gameObject; } } }
public void saveGame(Button buttonSave) { LoadAndSave loadAndSave = new LoadAndSave(); foreach (Law law in this.m_currentGameSessionLaws) { loadAndSave.ListCurrentLawId.Add(law.Id); } loadAndSave.CurrentLawId = this.m_currentLaw.Id; loadAndSave.GovernementOpinion = this.m_governmentOpinion; loadAndSave.PopulaceOpinion = this.m_populaceOpinion; loadAndSave.MoneyValue = this.m_personalMoney; loadAndSave.EconomyValue = this.m_economy; loadAndSave.EmploymentValue = this.m_employement; loadAndSave.ReligionValue = this.m_religion; loadAndSave.CurrentMonthInSemester = this.m_currentMonthInSemester; XmlSerializerHelper <LoadAndSave> .SerializeXmlFile(Application.streamingAssetsPath + "/PlayerSave.xml", loadAndSave); //buttonSave.GetComponentInChildren<Text>().text = "Game Saved"; }
public void LoadLevel(string levelName, LoadAndSave _saveGame) { fadeScreen.FadeOut(); GameManager.Instance.FireOnPause(); StartCoroutine(DelayedLoadLevel(levelName, _saveGame)); }
//Player Update Function that covers collision,controls,movement and inputs internal void Update(GameTime gameTime, List <GameObject> gameObjectsToRender, ref List <Enemy> enemyList, List <GameObject> interactiveObject, ref List <GameObject> gameObjects, LoadAndSave loadAndSave, IngameMenus ingameMenus, Levels levelManager, ref List <GameObject> allGameObjects, ShopKeeper shopKeeper, ItemUIManager itemUIManager, ref Boss hakume) { if (!playerSlowed) { movementSpeed = 10f; } if (!facingDirectionRight) { changeCollisionBox.X = 0; } else { changeCollisionBox.X = 50; } if (!shopKeeper.shopOpen) { PlayerControls(gameTime, enemyList, interactiveObject, ref gameObjects, loadAndSave, ingameMenus, gameObjects, shopKeeper, itemUIManager, hakume); } collisionBoxPosition = gameObjectPosition + changeCollisionBox; PlayerPositionCalculation(gameTime, gameObjectsToRender, interactiveObject); ItemCollisionManager(ref interactiveObject, ref gameObjects, levelManager, ref allGameObjects); if (invincibilityFrames) { InvincibleFrameState(gameTime); } Vibration(); }
public void RenderMainMenu(Dictionary<string, Texture2D> texturesDictionary, SpriteBatch spriteBatch, SpriteFont Font, Levels levelManager, LoadAndSave loadAndSave, ref List<GameObject> allGameObjects, ref Player player, Game1 game, Matrix transformationMatrix) { switch (currentState) { case Enums.MainMenuStates.MAIN: if (!controlWindowOpen) { switch (currentButton) { case Enums.MainMenuButtons.START: spriteBatch.Draw(texturesDictionary["MainMenu1"], new Rectangle(0, 0, 1920, 1080), Color.White); break; case Enums.MainMenuButtons.RESUME: spriteBatch.Draw(texturesDictionary["MainMenu2"], new Rectangle(0, 0, 1920, 1080), Color.White); break; case Enums.MainMenuButtons.OPTIONS: spriteBatch.Draw(texturesDictionary["MainMenu3"], new Rectangle(0, 0, 1920, 1080), Color.White); break; case Enums.MainMenuButtons.CREDITS: spriteBatch.Draw(texturesDictionary["MainMenu4"], new Rectangle(0, 0, 1920, 1080), Color.White); break; case Enums.MainMenuButtons.EXIT: spriteBatch.Draw(texturesDictionary["MainMenu5"], new Rectangle(0, 0, 1920, 1080), Color.White); break; } spriteBatch.DrawString(Font, "Neues Spiel", new Vector2(1400, 200), Color.Black, 0, new Vector2(0, 0), 1, SpriteEffects.None, 0); spriteBatch.DrawString(Font, "Fortfahren", new Vector2(1400, 360), Color.Black, 0, new Vector2(0, 0), 1, SpriteEffects.None, 0); spriteBatch.DrawString(Font, "Optionen", new Vector2(1400, 510), Color.Black, 0, new Vector2(0, 0), 1, SpriteEffects.None, 0); spriteBatch.DrawString(Font, "Credits", new Vector2(1400, 670), Color.Black, 0, new Vector2(0, 0), 1, SpriteEffects.None, 0); spriteBatch.DrawString(Font, "Verlassen", new Vector2(1400, 820), Color.Black, 0, new Vector2(0, 0), 1, SpriteEffects.None, 0); } if (controlWindowOpen) { newGameControlScreen(Font, spriteBatch, texturesDictionary, loadAndSave, ref allGameObjects, ref player, game); } break; case Enums.MainMenuStates.OPTION: options.drawOptions(spriteBatch, texturesDictionary, transformationMatrix, Font); break; } }
void newGameControlScreen(SpriteFont Font, SpriteBatch SpriteBatch, Dictionary<string, Texture2D> texturesDictionary, LoadAndSave loadAndSave, ref List<GameObject> allGameObjects, ref Player player, Game1 game1) { controlWindowOpen = true; if ((Keyboard.GetState().IsKeyDown(Keys.W) || Keyboard.GetState().IsKeyDown(Keys.Up) || GamePad.GetState(0).IsButtonDown(Buttons.DPadUp) || GamePad.GetState(0).ThumbSticks.Left.Y > 0.5f) && !controlButtonPressed && controlWindowOpen) { currentControlButton--; if (currentControlButton < Enums.MainMenuButtons.CONTROLYES) currentControlButton = Enums.MainMenuButtons.CONTROLNO; controlButtonPressed = true; } if ((Keyboard.GetState().IsKeyDown(Keys.S) || Keyboard.GetState().IsKeyDown(Keys.Down) || GamePad.GetState(0).IsButtonDown(Buttons.DPadDown) || GamePad.GetState(0).ThumbSticks.Left.Y < -0.5f) && !controlButtonPressed && controlWindowOpen) { currentControlButton++; if (currentControlButton > Enums.MainMenuButtons.CONTROLNO) currentControlButton = Enums.MainMenuButtons.CONTROLYES; controlButtonPressed = true; } switch (currentControlButton) { case Enums.MainMenuButtons.CONTROLYES: SpriteBatch.Draw(texturesDictionary["MainMenu1"], new Rectangle(0, 0, 1920, 1080), Color.White); break; case Enums.MainMenuButtons.CONTROLNO: SpriteBatch.Draw(texturesDictionary["MainMenu2"], new Rectangle(0, 0, 1920, 1080), Color.White); break; } if ((Keyboard.GetState().IsKeyDown(Keys.Enter)|| GamePad.GetState(0).IsButtonDown(Buttons.A)) && !controlButtonPressed) { switch (currentControlButton) { case Enums.MainMenuButtons.CONTROLYES: game1.NewGame(); LoadNewGame(loadAndSave); Game1.currentGameState = Game1.GameState.GAMELOOP; controlWindowOpen = false; break; case Enums.MainMenuButtons.CONTROLNO: controlWindowOpen = false; break; } controlButtonPressed = true; } if (Keyboard.GetState().GetPressedKeys().Count() == 0 && GamePad.GetState(0).IsButtonUp(Buttons.DPadUp) && GamePad.GetState(0).IsButtonUp(Buttons.A) && GamePad.GetState(0).IsButtonUp(Buttons.DPadDown) &&GamePad.GetState(0).ThumbSticks.Left.Y < 0.5f && GamePad.GetState(0).ThumbSticks.Left.Y > -0.5f) { controlButtonPressed = false; } SpriteBatch.DrawString(Font, "Ja", new Vector2(1400, 200), Color.Black, 0, new Vector2(0, 0), 1, SpriteEffects.None, 0); SpriteBatch.DrawString(Font, "Nein", new Vector2(1400, 360), Color.Black, 0, new Vector2(0, 0), 1, SpriteEffects.None, 0); SpriteBatch.DrawString(Font, "Echt jetzt?", new Vector2(1400, 50), Color.Black, 0, new Vector2(0, 0), 1, SpriteEffects.None, 0); }
//Contains Player Movement in all 4 directions and the attack private void PlayerControls(GameTime gameTime, List <Enemy> enemyList, List <GameObject> interactiveObject, ref List <GameObject> GameObjectsList, LoadAndSave loadAndSave, IngameMenus ingameMenus, List <GameObject> levelGameObjects, ShopKeeper shopKeeper, ItemUIManager itemUIManager, Boss hakume) { //using item: if ((Keyboard.GetState().IsKeyDown(Keys.F) || GamePad.GetState(0).IsButtonUp(Buttons.B)) && !previousState.IsKeyDown(Keys.B) && previousGamepadState.IsButtonDown(Buttons.B)) { int temp = itemUIManager.RemoveObject(); if (temp == (int)Enums.ObjectsID.HEALTHPOTION) { playerHP += 0.1f; if (playerHP >= 1f) { playerHP = 1f; } } if (temp == (int)Enums.ObjectsID.POWERPOTION) { playerDamage *= 2; } if (temp == (int)Enums.ObjectsID.JUMPPOTION) { defaultJumpValue = -22f; } } mouseState = Mouse.GetState(); if (!firstJump && !secondJump) { if (AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Left || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Hat_Left || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Armor_Left || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Armor_Hat_Left) { if (ItemUIManager.snailShellPickedUp && ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Hat_Left; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Hat_Left; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Left; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Left; } } if (AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Right || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Hat_Right || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Armor_Right || AnimationManager.currentAnimation == AnimationManager.Animations.Jump_Armor_Hat_Right) { if (ItemUIManager.snailShellPickedUp && ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Hat_Right; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Hat_Right; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Right; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Right; } } } if (!playerGameElementInteraction) { //if (Keyboard.GetState().IsKeyDown(Keys.P)) // ReducePlayerHP(); if (Keyboard.GetState().IsKeyDown(Keys.A) || GamePad.GetState(0).ThumbSticks.Left.X < -0.5f || GamePad.GetState(0).IsButtonDown(Buttons.DPadLeft)) { //Camera won't move after simple turning camera.IncreaseLeftCounter(); camera.ResetRightCounter(); //Camera moves to a direction so that you see better what is coming to you camera.cameraOffset(gameTime, false, true); if (firstJump == true || secondJump == true) { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Hat_Left; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Hat_Left; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Left; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Left; } } else { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Hat_Left; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Hat_Left; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Left; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Left; } } if (!playerGameElementInteraction) { velocity.X = -movementSpeed; } pressedLeftKey = true; facingDirectionRight = false; pressedRightKey = false; } else if (Keyboard.GetState().IsKeyDown(Keys.D) || GamePad.GetState(0).ThumbSticks.Left.X > 0.5f || GamePad.GetState(0).IsButtonDown(Buttons.DPadRight)) { //Camera won't move after simple turning camera.IncreaseRightCounter(); camera.ResetLeftCounter(); //Camera moves to a direction so that you see better what is coming to you camera.cameraOffset(gameTime, true, true); if (firstJump || secondJump) { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Hat_Right; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Right; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Hat_Right; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Right; } } else { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Hat_Right; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Armor_Right; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Hat_Right; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Walk_Right; } } if (!playerGameElementInteraction) { velocity.X = movementSpeed; } facingDirectionRight = true; pressedLeftKey = false; pressedRightKey = true; } else if (Keyboard.GetState().IsKeyDown(Keys.S) /*|| GamePad.GetState(0).IsButtonDown()*/) { velocity.Y = movementSpeed; } } //Player Jump Input if ((Keyboard.GetState().IsKeyDown(Keys.Space) && !previousState.IsKeyDown(Keys.Space) && !jumpButtonPressed) || (GamePad.GetState(0).IsButtonDown(Buttons.A) && !previousGamepadState.IsButtonDown(Buttons.A) && !jumpButtonPressed)) { if (facingDirectionRight) { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Hat_Right; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Right; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Hat_Right; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Right; } } else { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Hat_Left; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Armor_Left; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Hat_Left; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Jump_Left; } } jumpButtonPressed = true; playerGameElementInteraction = false; climbAllowed = false; isStanding = false; gravityActive = true; if (firstJump == false || secondJump == false) { jumpSpeed = defaultJumpValue; } PlayerJump(); //MUSIC if (secondJump != true) { audioManager.Play("ReggieJump"); } } //Player Attack Input if ((ButtonState.Pressed == mouseState.LeftButton && cooldown == 0 && !playerGameElementInteraction) || GamePad.GetState(0).IsButtonDown(Buttons.X) && cooldown == 0 && !playerGameElementInteraction) { audioManager.Play("ReggieAttack"); audioManager.Play("ReggieGroaning"); if (facingDirectionRight) { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Armor_Hat_Right; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Armor_Right; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Hat_Right; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Right; } } else { if (ItemUIManager.armorPickedUp && ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Armor_Hat_Left; } else if (ItemUIManager.armorPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Armor_Left; } else if (ItemUIManager.snailShellPickedUp) { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Hat_Left; } else { AnimationManager.nextAnimation = AnimationManager.Animations.Attack_Left; } } // TODO: Step1 activate enemyknockback at the specific currentframe, Step2 depending on the size of an enemy (how tall) //foreach (var enemy in enemyList) //{ // if (PlayerAttackCollision(enemy) && enemy.EnemyAliveState() == true && !enemy.invincibilityFrames) // { // enemy.invincibilityFrames = true; // //worm.KnockBackPosition(facingDirectionRight, 35); // enemy.KnockBackPosition(facingDirectionRight); // } //} if (ItemUIManager.currentItemEquipped.objectID == (int)Enums.ObjectsID.SCISSORS) { //Platform temp = null; playerDamage = 3; foreach (Platform platform in levelGameObjects.Cast <GameObject>().OfType <Platform>().ToList()) { if (DetectCollision(platform) && platform.PlatformType == (int)Enums.ObjectsID.SPIDERWEB) { //temp = platform; levelGameObjects.Remove(platform); break; } } //GameObjectsList.Remove(temp); } if (ItemUIManager.currentItemEquipped.objectID == (int)Enums.ObjectsID.SHOVEL) { movementSpeed = 20f; defaultJumpValue = 20f; } //TODO:Destroyable? temp // Platform temp = null; foreach (Platform platform in levelGameObjects.Cast <GameObject>().OfType <Platform>().ToList()) { if (DetectCollision(platform) && platform.PlatformType == (int)Enums.ObjectsID.VINEDOOR) { levelGameObjects.Remove(platform); break; } } //GameObjectsList.Remove(temp); foreach (Item item in levelGameObjects.Cast <GameObject>().OfType <Item>().ToList()) { if (item.objectID == (int)Enums.ObjectsID.APPLE) { if (item.gameObjectRectangle.Contains(this.gameObjectPosition)) { ingameMenus.saveAnimStart(); loadAndSave.Save(); Console.WriteLine("Game Saved"); break; } } } foreach (ShopKeeper shopkeeper in levelGameObjects.Cast <GameObject>().OfType <ShopKeeper>().ToList()) { if (shopkeeper.objectID == (int)Enums.ObjectsID.SHOPKEEPER) { if (shopkeeper.gameObjectRectangle.Contains(this.gameObjectPosition)) { shopKeeper.shopOpen = true; } else { shopKeeper.shopOpen = false; } } } playerAttackPressed = true; } if (playerAttackPressed) { attackTimer += (float)gameTime.ElapsedGameTime.Milliseconds / 100; if (attackTimer != 0 && attackTimer <= 0.5f) { foreach (var enemy in enemyList) { if (PlayerAttackCollision(enemy) && enemy.EnemyAliveState() == true && !enemy.invincibilityFrames) { enemy.invincibilityFrames = true; enemy.KnockBackPosition(facingDirectionRight, playerDamage); //enemy.KnockBackPosition(facingDirectionRight); } } if (PlayerAttackCollision(hakume)) { hakume.ReduceEnemyHP(playerDamage); } } else { attackTimer = 0; } cooldown += (float)gameTime.ElapsedGameTime.TotalSeconds * 2; } if (cooldown >= .75) { cooldown = 0; playerAttackPressed = false; } //Player Gameelement Interactive Input if ((ButtonState.Pressed == mouseState.RightButton || Keyboard.GetState().IsKeyDown(Keys.W) || GamePad.GetState(0).IsButtonDown(Buttons.DPadUp) && !playerGameElementInteraction && !previousState.IsKeyDown(Keys.W) && !previousGamepadState.IsButtonDown(Buttons.DPadUp))) { foreach (var vine in interactiveObject) { if (DetectCollision(vine)) { jumpSpeed = 0; gravityActive = false; isStanding = true; firstJump = false; secondJump = false; jumpButtonPressed = false; playerGameElementInteraction = true; pressedLeftKey = false; pressedRightKey = false; velocity.X = 0; collisionBoxPosition.X = vine.gameObjectRectangle.X; if (gameObjectPosition != collisionBoxPosition - changeCollisionBox) { gameObjectPosition = collisionBoxPosition - changeCollisionBox; } } } } if ((Keyboard.GetState().IsKeyDown(Keys.W) || GamePad.GetState(0).IsButtonDown(Buttons.DPadUp)) && playerGameElementInteraction) { climbAllowed = false; velocity.X = 0; velocity.Y = -movementSpeed - 2; foreach (var vine in interactiveObject) { if (Math.Abs(collisionBoxPosition.X - vine.gameObjectRectangle.X) <= 5) { collisionBoxPosition.X = vine.gameObjectRectangle.X; if (collisionRectangle.Bottom + velocity.Y >= vine.gameObjectRectangle.Top + 30) { climbAllowed = true; } } } if (gameObjectPosition != collisionBoxPosition - changeCollisionBox) { gameObjectPosition = collisionBoxPosition - changeCollisionBox; } if (climbAllowed) { velocity.Y = -movementSpeed - 2; } else { velocity.Y = 0; } } else if ((Keyboard.GetState().IsKeyDown(Keys.S) || GamePad.GetState(0).IsButtonDown(Buttons.DPadDown)) && playerGameElementInteraction) { climbAllowed = false; velocity.X = 0; velocity.Y = movementSpeed + 2; foreach (var vine in interactiveObject) { if (Math.Abs(collisionBoxPosition.X - vine.gameObjectRectangle.X) <= 5) { collisionBoxPosition.X = vine.gameObjectRectangle.X; if (collisionRectangle.Top + velocity.Y <= vine.gameObjectRectangle.Bottom - 80) { climbAllowed = true; } } } if (gameObjectPosition != collisionBoxPosition - changeCollisionBox) { gameObjectPosition = collisionBoxPosition - changeCollisionBox; } if (climbAllowed) { velocity.Y = movementSpeed + 2; } else { velocity.Y = 0; } } if (Keyboard.GetState().IsKeyUp(Keys.D) && Keyboard.GetState().IsKeyUp(Keys.A) && !firstJump && !secondJump && !playerGameElementInteraction) { if (facingDirectionRight) { camera.cameraOffset(gameTime, false, false); } if (!facingDirectionRight) { camera.cameraOffset(gameTime, true, false); } } previousState = Keyboard.GetState(); previousGamepadState = GamePad.GetState(0); }
// Use this for initialization public void Initinal(int stageNum, LoadAndSave _PlayerData, StageChallange stageChallange, AIGameManger _aIGameManger) { ////aIStateController = new AIStateController(); //m_Controller = new AvaterController(); ////m_Controller = new CharacterControlMove(); ////m_Controller.Player = GameObject.Find("Player"); //m_Controller.Player =GameObject.Instantiate( Resources.Load<GameObject>("Player"), _PlayerData.m_datainfolist.playerdata.LastPos,Quaternion.identity); //m_Controller.Player.name = "Player"; //m_Controller.Initialized(); //m_Controller.Player.GetComponent<NewPlayerController>().maogame = this; //m_Controller.Player.GetComponent<NewPlayerController>()._data = _PlayerData; //TurnStage = false; //GameObject.FindObjectOfType<CameraFollow>().Player = m_Controller.Player; //if(!_PlayerData.m_datainfolist.stageData.Pass) //{ // //creat door or sendmessange to scene obj // GameObject.FindObjectOfType<StageChallange>().Initialized(_aIGameManger,_PlayerData); //} //else //{ // // // GameObject.FindObjectOfType<StageChallange>().PassInitialized(_aIGameManger,_PlayerData); //} //if(GameObject.FindObjectOfType<teach>() != null) //{ // GameObject.FindObjectOfType<teach>().Player = m_Controller.Player; //} ////------ //TreeManger treeManger = GameObject.FindObjectOfType<TreeManger>(); //treeManger.Initialized(_PlayerData,m_Controller.Player.transform); //if(GameObject.FindObjectOfType<NewMiniMap>()!=null) //{ // NewMiniMap minimap = GameObject.FindObjectOfType<NewMiniMap>(); // minimap.InitializedMapRange(m_Controller.Player); //} //aIStateController = new AIStateController(); //Player = GameObject.Instantiate(Resources.Load<GameObject>("Player"), _PlayerData.m_datainfolist.playerdata.LastPos, Quaternion.identity); Player = GameObject.FindGameObjectWithTag("Player"); Player.name = "Player"; Player.GetComponent <NewPlayerController>().maogame = this; Player.GetComponent <NewPlayerController>()._data = _PlayerData; TurnStage = false; GameObject.FindObjectOfType <CameraFollow>().Player = Player; if (!_PlayerData.m_datainfolist.stageData.Pass) { //creat door or sendmessange to scene obj GameObject.FindObjectOfType <StageChallange>().Initialized(_aIGameManger, _PlayerData); } else { // GameObject.FindObjectOfType <StageChallange>().PassInitialized(_aIGameManger, _PlayerData); Player.transform.position = _PlayerData.m_datainfolist.playerdata.LastPos; } if (GameObject.FindObjectOfType <teach>() != null) { GameObject.FindObjectOfType <teach>().Player = Player; } //------ TreeManger treeManger = GameObject.FindObjectOfType <TreeManger>(); treeManger.Initialized(_PlayerData, Player.transform); if (GameObject.FindObjectOfType <NewMiniMap>() != null) { NewMiniMap minimap = GameObject.FindObjectOfType <NewMiniMap>(); minimap.InitializedMapRange(Player); } }
/// <summary> /// Draws the Level Editor UI and finds out if element was clicked /// </summary> /// <param name="texturesDictionary"></param> /// <param name="spriteBatch"></param> /// <param name="transformationMatrix"></param> /// <param name="gameObjectList"></param> /// <param name="graphics"></param> public void DrawLvlEditorUI(Dictionary <string, Texture2D> texturesDictionary, SpriteBatch spriteBatch, Matrix transformationMatrix, ref List <GameObject> gameObjectList, ref List <GameObject> levelGameObjects, GraphicsDevice graphics, ref LoadAndSave loadAndSave, ref Levels levelManager) { int j = 0; MouseState mouseState = Mouse.GetState(); Vector2 firstPosition = new Vector2(1750, 200); Vector2 transformedPos_firstPosition = Vector2.Transform(firstPosition, Matrix.Invert(transformationMatrix)); spriteBatch.Draw(texturesDictionary["Transparent_500x50"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Transparent_1000x50"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Climbingplant_38x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Transparent_64x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; for (int i = 0; i < PlatformsDic.Count(); i++) { spriteBatch.Draw(Platform_TileSheet, transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), PlatformsDic.ElementAt(i).Value, Color.White, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 0); j++; } spriteBatch.Draw(texturesDictionary["SnailShell"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Armor_64x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Shovel_64x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Scissors_64x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["HealthItem"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["PowerPotion"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["JumpPotion"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["GoldenUmbrella"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Spiderweb_64x64"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["VineDoor"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["Apple"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; j++; spriteBatch.Draw(texturesDictionary["EnemySpawnPoint"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; spriteBatch.Draw(texturesDictionary["cornnency"], transformedPos_firstPosition + j * new Vector2(0, 100) - new Vector2(0, yoffset), Color.White); j++; if (ButtonState.Pressed == mouseState.LeftButton && !button1Pushed) { Vector2 transformedPos = Vector2.Transform(new Vector2(1000, 200), Matrix.Invert(transformationMatrix)); Rectangle checkRectangle; button1Pushed = true; for (int i = 4; i < PlatformsDic.Count() + 4; i++) { checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + i * 100 - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { createNewPlatform(ref gameObjectList, PlatformsDic.ElementAt(i - 4).Key, transformationMatrix, graphics, texturesDictionary); } } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + 0 * 100 - yoffset, 500, 50); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["Transparent_500x50"], new Vector2(512, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.INVISIBLE_WALL_500x50, false)); gameObjectList.Last().DontDrawThisObject(); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + 1 * 100 - yoffset, 1000, 50); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["Transparent_1000x50"], new Vector2(1024, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.INVSIBLE_WALL_1000x50, false)); gameObjectList.Last().DontDrawThisObject(); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + 2 * 100 - yoffset, 38, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["Climbingplant_38x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.VINE, (int)Enums.ObjectsID.VINE, false)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + 3 * 100 - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["Transparent_64x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.INVISIBLE_WALL_64x64, false)); gameObjectList.Last().DontDrawThisObject(); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 4) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["SnailShell"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.SNAILSHELL)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 5) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["Armor_64x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.ARMOR)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 6) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["Shovel_64x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.SHOVEL)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 7) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["Scissors_64x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.SCISSORS)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 8) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["HealthItem"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.HEALTHPOTION)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 9) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["PowerPotion"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.POWERPOTION)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 10) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["JumpPotion"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.JUMPPOTION)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 11) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["GoldenUmbrella"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.GOLDENUMBRELLA)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 12) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["Spiderweb_64x64"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.SPIDERWEB, false)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 13) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["VineDoor"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.VINEDOOR, false)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 14) * 100) - yoffset, 128, 128); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["Apple"], new Vector2(128, 128), transformedPos, (int)Enums.ObjectsID.APPLE)); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 16) * 100) - yoffset, 64, 64); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Platform(texturesDictionary["EnemySpawnPoint"], new Vector2(64, 64), transformedPos, (int)Enums.ObjectsID.PLATFORM, (int)Enums.ObjectsID.ENEMYSPAWNPOINT, true)); gameObjectList.Last().DontDrawThisObject(); } checkRectangle = new Rectangle((int)firstPosition.X, (int)firstPosition.Y + ((PlatformsDic.Count() + 17) * 100) - yoffset, 128, 128); if (checkRectangle.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { gameObjectList.Add(new Item(texturesDictionary["cornnency"], new Vector2(128, 128), transformedPos, (int)Enums.ObjectsID.CORNNENCY)); } } if (ButtonState.Released == mouseState.LeftButton) { button1Pushed = false; } Color color = new Color(); Vector2 positionBackButton = new Vector2(1550, 900); Vector2 transformedBackButton = Vector2.Transform(positionBackButton, Matrix.Invert(transformationMatrix)); Rectangle rectangleBackButton = new Rectangle((int)positionBackButton.X, (int)positionBackButton.Y, 200, 50); if (rectangleBackButton.Contains(new Point((int)mousePosition.X, (int)mousePosition.Y))) { if (ButtonState.Pressed == mouseState.LeftButton && !button2Pushed) { button2Pushed = true; color = Color.LightGray; foreach (GameObject gameObject in gameObjectList) { levelGameObjects.Add(gameObject); } levelManager.sortGameObjects(); loadAndSave.Save(); } else { color = Color.White; } } else { button2Pushed = false; color = Color.White; } spriteBatch.Draw(texturesDictionary["LevelEditorUIBackButton"], transformedBackButton, color); }
//更新函数 void FixedUpdate() { if (Input.anyKey && !isStart) { isStart = true; data.init(); gameStart(); } if (this.mode != MainGame.MODE_FIGHT) { this.autoSaveTime += Time.fixedDeltaTime; if (this.autoSaveTime >= this.autoSaveMaxTime) { this.autoSaveTime = 0; LoadAndSave.saveNpc(myNpc, myNpc.id); } } /******************* *更新战斗相关 * * *******************/ if (this.mode == MainGame.MODE_FIGHT) { myNpc.speedTime += Time.fixedDeltaTime; if (myNpc.speedTime >= (this.myNpc.norFightSpeed * (1f + this.myNpc.fightSpeedAmp))) { myNpc.speedTime = (this.myNpc.norFightSpeed * (1f + this.myNpc.fightSpeedAmp)); myNpc.isCanFight = true; } else { myNpc.isCanFight = false; } enemyNpc.speedTime += Time.fixedDeltaTime; if (enemyNpc.speedTime >= (this.enemyNpc.norFightSpeed * (1f + this.enemyNpc.fightSpeedAmp))) { enemyNpc.speedTime = (this.enemyNpc.norFightSpeed * (1f + this.enemyNpc.fightSpeedAmp)); enemyNpc.isCanFight = true; } else { enemyNpc.isCanFight = false; } fightNpcAI(enemyNpc, myNpc); switch (updateNpcStatus()) { case 0: break; case 1: //myNpc失败 textEvent.setNotice("很遗憾你输掉了战斗\n作为惩罚将扣除你当前经验的50%", 1.5f, true); endFight(enemyNpc, myNpc); break; case 2: //enemyNpc失败 textEvent.setNotice("恭喜你赢得了战斗", 1.5f, true); endFight(myNpc, enemyNpc); break; } } /******************* *文本相关 * * *******************/ if (isShowStatusPanel) { uploadStatus(this.myNpc); } /******************* *更新按键 * * *******************/ if (xuanXiangTime < 1000f) { xuanXiangTime += Time.fixedDeltaTime; } if (this.mode != MainGame.MODE_MOVE) { buttonList.get(choseXuanXiang).GetComponent <Button>().Select(); } }