public Game(string Path, uint _minLen, uint _maxLen) { player = new Player[2]; player[0] = new Player(); player[1] = new Player(); minLen = _minLen; maxLen = _maxLen; words = Input.ReadWords(Path); CurrentPlayer = 0; if (words.Count == 0) throw new Exception("No words!"); words.Sort(new WordComparerLen()); // Унифицировать слова в словаре (маЛо Ли чТо там Будет) for (int i = 0; i < words.Count; ++i) words[i] = words[i].ToUpper(); UsedWord = new bool[words.Count]; if (words.Count > 0) { for (int i = 0; i < words.Count; ++i) UsedWord[i] = false; CurrentWordID = GetRandomWordID(); if (CurrentWordID < 0) { throw new Exception("No such words!"); } else UsedWord[CurrentWordID] = true; } }
/// <summary> /// Passes method to block. /// </summary> /// <returns> /// The action. /// </returns> /// <param name='p'> /// If set to <c>true</c> p. /// </param> /// <param name='l'> /// If set to <c>true</c> l. /// </param> /// <param name='l2'> /// If set to <c>true</c> l2. /// </param> public IPlace AutomaticAction(Player p) { if (Script == null) this.Block = Block.AutomaticAction(p); else { ThisGame.lua["map"] = ThisGame.dungeon; ThisGame.lua["block"] = Block; ThisGame.lua.DoFile(ThisGame.filePath + "luascripts/dungeons/" + ThisGame.player.currentDungeon + "/" + Script); Block = (IPlace)ThisGame.lua["out"]; bool keepScript = (bool)ThisGame.lua["keepscript"]; string message = (string)ThisGame.lua["message"]; if (message != "null") ThisGame.messageLog.Enqueue(message); if (!keepScript) { if ((string)ThisGame.lua["newscript"] == "null") Script = null; else Script = (string)ThisGame.lua["newscript"]; } UpdateSymbol(); ThisGame.lua["block"] = null; ThisGame.lua["out"] = null; ThisGame.lua["keepscript"] = null; ThisGame.lua["newscript"] = null; ThisGame.lua["message"] = null; } return this; }
// constructeur public Afficheur() { localplayer = new Player(); enemy = new Enemy(); affichemenu = new MainMenu(); scrolling = new Scroll(); }
public void endGame() { //we're letting garabage collector clean up memory condition = new ReadyCondition(); //Change state correct_elevator = null; wrong_elevator = null; floors = null; player = null; }
public override void Create(CharData charData, ViewMap viewMap) { _viewMap = viewMap; gameObj = new Player(); gameObj.Init(charData, viewMap.LogicMap); gameGo = GameObject.CreatePrimitive(PrimitiveType.Cube); gameGo.name = charData.name; gameTrans = gameGo.transform; }
public int AddPlayer() { if (!_canAddPlayers) throw new InvalidOperationException("You cannot add players after the game is started."); var playerId = _players.Count + 1; _players[playerId] = new Player(playerId); return playerId; }
public HauntedBuilding() { condition = new ReadyCondition(); difficulty = 0; //Maybe part of GameCondition? title = "Welcome to Haunted Building\n"; floors = null; player = null; correct_elevator = null; wrong_elevator = null; }
/// <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() { // TODO: Add your initialization logic here player = new Player(); Window.Title = "GETREKT!"; colliderList = new ArrayList(); base.Initialize(); }
public void LoadSkillNew(Game.CharacterStats character, Game.CharacterStats.SkillType skillToLoad, int trainerMaxRank) { this.m_trainFailReason = string.Empty; this.m_skillType = skillToLoad; this.LblName.text = Game.GUIUtils.GetSkillTypeString(this.m_skillType); bool flag = false; float skillPerRankMultiplier = StatsData.Instance.GetSkillPerRankMultiplier(this.m_skillType); int skillRank = character.GetSkillRank(this.m_skillType); this.m_skillXP = character.SkillXP[(int)this.m_skillType]; this.m_nextRankXP = Game.CharacterStats.ExperienceNeededForNextSkillRank(skillRank, skillPerRankMultiplier); this.LblRank.text = string.Format(SDK.GUIUtils.GetText(291), skillRank, trainerMaxRank); this.LblRank.color = UIGlobalColor.FetchColor(UIGlobalColor.ColorLookupID.TEXT_NORMAL_DEFAULT); this.ProgressRank.fillAmount = (float)this.m_skillXP / (float)this.m_nextRankXP; if (skillRank + 1 > trainerMaxRank) { this.m_trainFailReason = string.Format(SDK.GUIUtils.GetText(2129), trainerMaxRank); this.LblRank.color = UIGlobalColor.FetchColor(UIGlobalColor.ColorLookupID.TEXT_UNAFFORDABLE); flag = true; } if (character.SkillsTrainedThisLevel >= character.Level * 5) { this.m_trainFailReason = SDK.GUIUtils.GetText(2132); } int num = Game.CharacterStats.CopperCostToTrainSkillToNextRank(skillRank + 1); Game.Player s_playerCharacter = Game.GameState.s_playerCharacter; if (s_playerCharacter == null) { return; } Game.PlayerInventory component = s_playerCharacter.GetComponent <Game.PlayerInventory>(); if (component == null) { return; } bool flag2 = component.currencyTotalValue >= (float)num; this.CostView.ShowCost(num, flag2); if (!flag2) { this.m_trainFailReason = SDK.GUIUtils.GetText(2128); } this.ButtonMain.IsEnabled = (this.m_trainFailReason.Length == 0); if (!flag && !this.ButtonMain.IsEnabled) { this.LblRank.color = UIGlobalColor.FetchColor(UIGlobalColor.ColorLookupID.TEXT_NORMAL_DISABLED); } if (this.m_isHovered && this.m_trainFailReason.Length != 0) { this.OnTrainSkillHovered(this.ButtonTrain.gameObject, true); } }
/// <summary> /// 指定された名前のJsonファイルを読みに行って、その中身をステージ上に出す /// </summary> /// <param name="stagename"></param> public static void Load(string stagename) { TextAsset asset = Resources.Load("StageJson/" + stagename) as TextAsset; if(asset == null) { Debug.Log("ステージ読み込めなかった(ステージ名:" + stagename + ")"); return; } JsonNode json = JsonNode.Parse(asset.text); GameSetting.TimeLimit = (int)json["TimeLimit"].Get<long>(); GameSetting.SlotCount = (int)json["SlotCount"].Get<long>(); GameSetting.StageName = stagename; Transform parent; parent = (GameObject.Find("/Players") as GameObject).transform; foreach (var item in json["Players"]) { GameObject g = new Player(item).Load(); if (g != null) g.transform.SetParent(parent); } parent = (GameObject.Find("/Terrains") as GameObject).transform; foreach(var item in json["Terrains"]) { GameObject g = new Terrain(item).Load(); if (g != null) g.transform.SetParent(parent); } parent = (GameObject.Find("/Gimmicks") as GameObject).transform; foreach (var item in json["Gimmicks"]) { GameObject g = new Gimmick(item).Load(); if (g != null) g.transform.SetParent(parent); } parent = (GameObject.Find("/Flags") as GameObject).transform; foreach (var item in json["Flags"]) { GameObject g = new Flag(item).Load(); if (g != null) g.transform.SetParent(parent); } parent = (GameObject.Find("/Items") as GameObject).transform; foreach (var item in json["Items"]) { GameObject g = new Item(item).Load(); if (g != null) g.transform.SetParent(parent); } }
public void Start() { m_animator = GetComponent<Animator>(); m_collider = GetComponent<Collider2D>(); m_renderer = GetComponent<SpriteRenderer>(); if (m_animator != null) m_isCollectedHash = Animator.StringToHash("isCollected"); if (m_renderer != null) m_initialSprite = m_renderer.sprite; mPlayer = Player.Get(); mCoreNumber = ++mCoreCounter; }
public void teleport(Player player) { if (player == null || mTeleportTarget == null || mState == STATE.INACTIVE) return; // Woohoo! Lambda functions! GameManager.Get().delayFunction(() => { mCanTeleport = false; mCollider.size = new Vector2(mBaseSize.x, mBaseSize.y * 2); mCollider.offset = new Vector2(mBaseOffset.x, mBaseOffset.y + mBaseSize.y / 2); player.transform.position = getSpawnPosition(); }); }
public void Start() { Player ___p100; ___p100 = new Player(0); SpawnAmount = 2f; ScoreText = new CnvText("Text/Score",true); Players = ( (new Cons<Player>(___p100,(new Empty<Player>()).ToList<Player>())).ToList<Player>()).ToList<Player>(); GameReady = false; GameOverText = new CnvText("Text/GameOver",false); GameOver = false; CurrentPlayer = ___p100; Asteroids = ( Enumerable.Empty<Asteroid>()).ToList<Asteroid>(); }
// calculate visibility - how far does the player see? public void CalculateVisibility(Player p, int visibility) { int x = p.X; int y = p.Y; double dist; for (int i = Math.Max(x-visibility,0); i <= Math.Min(x+visibility,this.Width-1); i++) { for (int j = Math.Max(y-visibility,0); j <= Math.Min(y+visibility,this.Heigth-1); j++) { dist = Math.Sqrt((i-x)*(i-x) + (j-y)*(j-y)); if (dist < visibility) { location[i,j].Visible = true; } } } }
public Game(string Path, int minL, int maxL) { Players = new Player[2]; Players[0] = new Player(); Players[1] = new Player(); CurrentPlayer = 0; minLen = minL; maxLen = maxL; Words = new List<string>(); ReadWords(Path); UsedWord = new bool[Words.Count]; if (Words.Count > 0) { for (int i = 0; i < Words.Count; ++i) UsedWord[i] = false; CurrentWordID = GetRandomWordID(); UsedWord[CurrentWordID] = true; } }
public static void NewGame(Player currentplayer, bool singleplayer, Size gamesize) { if (InGame) { QuitGame(); return; } CurrentPlayer = currentplayer; SingplePlayer = singleplayer; GameSize = gamesize; var rand = new Random(); if (SingplePlayer) { for (int i = 0; i < 5; i++) { Players.Add(new Player(new Point(rand.Next(GameSize.Width), rand.Next(GameSize.Height)), "Bot" + (i + 1), null)); } } }
public static Player CreateNewPlayer() { // Pick name Console.WriteLine("What is your name?"); string name = Console.ReadLine().Trim(); // lets egyptize the name int choice = 0; string userInput = ""; string[] names = {(name.ToLower() + "nefer").ToUpperFirstLetter(), (name.ToLower() + "hotep").ToUpperFirstLetter(), "Ptah" + name.ToLower() + "tep", "Nefe" + name.ToLower() + "bet", "Ankh" + name.ToLower() + "amun", "Iset" + name.ToLower() + "rure", "Neb" + name.ToLower() + "kare"}; while (choice < 1 || choice > 7) { Console.WriteLine("That sounds just bad. What about:"); for (int i=0; i<names.Length; i++) Console.WriteLine("\t{0}: {1}", i+1, names[i]); userInput = Console.ReadLine(); int.TryParse(userInput, out choice ); } // create new name string newname = names[choice-1]; Characteristics ch = new Characteristics(10,2,1,0); Characteristics ch2 = new Characteristics(10,2,1,0); Player p = new Player(newname, ch, ch2, 100, 2, 2); p.SetCurrentDungeon("dungeon1"); Item amulet = new Item("Amulet with crocodile"); p.PickItem(amulet); Console.Clear(); Console.WriteLine("You wake up."); Console.WriteLine("Your head is spinning and you feel throbbing pain on the back of your head."); Console.WriteLine("There is pitch dark all around you, not a single ray of light. And who are you, anyway?"); Console.ReadKey(); Console.WriteLine("Oh yes, your name is {0} and you were building the tomb for Khasekhemre, pharaohs chief accountant.", newname); Console.WriteLine("And thats the last thing you remember"); Console.ReadKey(); Console.WriteLine("You should probably find out what happened."); Console.ReadKey(); return p; }
public void DrawPlayer(Player player, bool clear) { if (player.Avatar == null) Gr.FillRectangle((clear) ? Brushes.Black : Brushes.Blue, player.Position.X - Game.CurrentPlayer.Position.X - AvatarSize, player.Position.Y - Game.CurrentPlayer.Position.Y - AvatarSize, 2 * AvatarSize, 2 * AvatarSize); else { if (!clear) Gr.DrawImage(player.Avatar, new Point { X = player.Position.X - Game.CurrentPlayer.Position.X - player.Avatar.Width, Y = player.Position.Y - Game.CurrentPlayer.Position.Y - player.Avatar.Height }); else Gr.FillRectangle(Brushes.Black, player.Position.X - Game.CurrentPlayer.Position.X - player.Avatar.Width, player.Position.Y - Game.CurrentPlayer.Position.Y - player.Avatar.Height, player.Avatar.Width, player.Avatar.Height); } }
public Game(DungeonVandal.MenuForm form,string player_name) { Form = form; graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = Form.ViewportSize.Width, PreferredBackBufferHeight = Form.ViewportSize.Height }; player = new Player(player_name); Form.setPlayerName(player.Name); graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings; System.Windows.Forms.Control.FromHandle(Window.Handle).VisibleChanged += MainGame_VisibleChanged; System.Windows.Forms.Control.FromHandle(Form.Handle).KeyUp += new System.Windows.Forms.KeyEventHandler(Game_KeyUp); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyDown += new System.Windows.Forms.KeyEventHandler(Game_Key); // System.Windows.Forms.Control.FromHandle(Form.Handle).KeyPress += new System.Windows.Forms.KeyPressEventHandler(Game_KeyPress); Content.RootDirectory = "Content"; IsMouseVisible = true; }
private void ArmorsAvaliableForSell(Player customer) { var listOfArmorNames = armorsToSell.Keys.ToList(); var listOfArmorPrices = armorsToSell.Values.ToList(); int choice; bool parseSuccessfull; do { ; PrintDesign.WriteLineInGreen($"\nGold in wallet: {customer.Gold}"); PrintDesign.PrintShop(armorsToSell); Console.Write("Number: "); parseSuccessfull = int.TryParse(Console.ReadLine(), out choice); if (choice <= 0) { Console.Clear(); PrintDesign.WriteLineInRed("Chosen number to small!"); } else if (parseSuccessfull == false) { Console.Clear(); PrintDesign.WriteLineInRed("Something went wrong!"); } else if (choice >= 4) { Console.Clear(); PrintDesign.WriteLineInRed("Chosen number to high!"); } } while (choice >= 4 || choice <= 0 || parseSuccessfull == false); if (listOfArmorPrices[choice - 1] > customer.Gold) { Console.Clear(); PrintDesign.WriteLineInRed($"You dont have enough money to buy {listOfArmorNames[choice - 1]}!"); } else if (customer.Armor.Contains(listOfArmorNames[choice - 1])) { Console.Clear(); PrintDesign.WriteLineInRed($"You already {listOfArmorNames[choice - 1]}!"); } else { PrintDesign.WriteLineInGreen($"\n{listOfArmorNames[choice - 1]} bought and equipped!"); customer.Armor = listOfArmorNames[choice - 1]; customer.Gold -= listOfArmorPrices[choice - 1]; if (choice == 1) { customer.MaxBlock -= ExtraDefenceFromArmor; // tar bort nuvarande bonusen från armor ExtraDefenceFromArmor = 3; customer.MaxBlock += ExtraDefenceFromArmor; // addrar bonusen från den nyköpta armor } if (choice == 2) { customer.MaxBlock -= ExtraDefenceFromArmor; ExtraDefenceFromArmor = 5; customer.MaxBlock += ExtraDefenceFromArmor; } if (choice == 3) { customer.MaxBlock -= ExtraDefenceFromArmor; ExtraDefenceFromArmor = 7; customer.MaxBlock += ExtraDefenceFromArmor; } } }
public void Kill(Player killer) { KillEvent(this, new PlayerKillEventArgs(this, killer)); Game.Players.Remove(this); }
private void SpecialItemsAvaliableForSell(Player customer) { var listOfItemNames = specialItemsToSell.Keys.ToList(); // hämmtar namnet på special item till salu var listOfItemPrices = specialItemsToSell.Values.ToList(); // hämtar värdet på special item till salu. int choice; bool parseSuccessfull; do { PrintDesign.WriteLineInGreen($"\nGold in wallet: {customer.Gold}"); PrintDesign.PrintShop(specialItemsToSell); Console.Write("Number: "); parseSuccessfull = int.TryParse(Console.ReadLine(), out choice); if (choice < 0) { PrintDesign.WriteLineInRed("Chosen number to small!"); } else if (parseSuccessfull == false) { PrintDesign.WriteLineInRed("Something went wrong!"); } else if (choice > 4) { PrintDesign.WriteLineInRed("Chosen number to high!"); } } while (choice >= 4 || choice <= 0 || parseSuccessfull == false); if (listOfItemPrices[choice - 1] > customer.Gold) { Console.Clear(); PrintDesign.WriteLineInRed($"You dont have enough money to buy {listOfItemNames[choice - 1]}!"); } else if (customer.SpecialItem == listOfItemNames[choice - 1]) { Console.Clear(); PrintDesign.WriteLineInRed($"You already own {listOfItemNames[choice - 1]}!"); } else { Console.Clear(); PrintDesign.WriteLineInGreen($"\n{listOfItemNames[choice - 1]} bought and equipped!"); customer.SpecialItem = listOfItemNames[choice - 1]; // adderar special item till spelaren customer.Gold -= listOfItemPrices[choice - 1]; // tar bort det antal guld från spelaren som den köpta varan kostar. if (choice == 1) { customer.Health -= ExtraHealthFromItems; ExtraHealthFromItems = 1; customer.Health += ExtraHealthFromItems; } if (choice == 2) { customer.Health -= ExtraHealthFromItems; ExtraHealthFromItems = 2; customer.Health += ExtraHealthFromItems; } if (choice == 3) { customer.Health -= ExtraHealthFromItems; ExtraHealthFromItems = 3; customer.Health += ExtraHealthFromItems; } } }
public void Draw(Player p) { int w = Console.WindowWidth; int h = ThisGame.mapHeight; int diffx = (int)Math.Ceiling((double)(w/2)) - p.X; int diffy = (int)Math.Ceiling((double)(h/2)) - p.Y; for (int i = 3; i<w-2; i++) { for (int j = 2; j<h-1; j++) { try { Console.CursorLeft = i; Console.CursorTop = j; if (this.location[i-diffx,j-diffy].Visible) Console.Write(this.location[i-diffx,j-diffy].Symbol()); else Console.Write('?'); } catch { Console.Write('?'); } } } for (int i = 0; i<w; i++) { Console.CursorLeft = i; Console.CursorTop = h; Console.Write('='); } }
/// <summary> /// Konstruktor �aduj�cy zapisan� gr� /// </summary> /// <param name="player">Instancja gracza</param> /// <param name="game_state_data_to_load">Dane stany gry do �adowania</param> /// <param name="data_index">Indeks danych w tablicy stan�w gry</param> public void SavedGame(Player player, GameState.GameStateData game_state_data_to_load, int data_index) { this.player = player; data_to_load = game_state_data_to_load; if (data_to_load.Count != 0) game_map = new Map.Map(tile_size, map_width, map_height, data_to_load.GameMaps[data_index], this.Content, player); music = Content.Load<Song>("Audio\\background_music"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(music); if (!player.AudioSettings.IsMuted) MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; else MediaPlayer.Volume = 0; MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; this.data_index = data_index; this.player.Dynamite = data_to_load.Dynamites[data_index]; this.player.Points = data_to_load.Points[data_index]; this.player.Rackets = data_to_load.Rackets[data_index]; totalMinutes = data_to_load.TotalMinutes[data_index]; totalSeconds = data_to_load.TotalSeconds[data_index]; Form.Invoke(new Action(() => Form.game_panel.playerName.Text = player.Name)); graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings; System.Windows.Forms.Control.FromHandle(Window.Handle).VisibleChanged += MainGame_VisibleChanged; System.Windows.Forms.Control.FromHandle(Form.Handle).KeyUp += new System.Windows.Forms.KeyEventHandler(Game_KeyUp); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyPress += new System.Windows.Forms.KeyPressEventHandler(Game_KeyPress); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyDown += new System.Windows.Forms.KeyEventHandler(Game_Key); System.Windows.Forms.Control.FromHandle(Form.Handle).PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(Game_PreviewKeyDown); IsMouseVisible = true; isStarted = true; }
public IPlace AutomaticAction(Player p) { // there always will be a script to handle interaction of player and another being return this; }
public Game(Rectangle boundaries) { this.boundaries = boundaries; player = new Player(this, new Point(boundaries.Left + 10, boundaries.Top + 70), boundaries); }
/// <summary> /// Initialization of the static class /// </summary> /// <param name="form_insert"></param> /// <param name="Brick_Width"></param> /// <param name="Brick_Height"></param> /// <param name="seed"></param> public static void Init(GameWindow form_insert, int Brick_Width, int Brick_Height, Menu m, int seed = -1) { StateSaver.Reset(); StateSaver.SetGameState(StateSaver.GameStates.BricksAlive); form = form_insert; menu = m; if (ReplaySaver.IsReplay) { seed = ReplaySaver.seed; } //If there is a given seed, use that one (debug reasons) if (seed == -1) random = new Random(); else random = new Random(seed); Console.WriteLine("Seed " + seed); ReplaySaver.seed = seed; //boundingbox gameField = new RectangleF( GameSettings.GamefieldOffsetWidth, GameSettings.GamefieldOffsetHeight, GameSettings.BrickOffsetWidth * 2 + Brick_Width * (GameSettings.BrickSpacingWidth + GameSettings.BrickSizeWidth), GameSettings.BrickOffsetHeight + 100 + Brick_Height * (GameSettings.BrickSpacingHeight + GameSettings.BrickSizeHeight)); //Fill bricks Debug.Print("" + seed); bricks = new Brick[Brick_Width, Brick_Height]; FillBricks(); numberOfBricks = Brick_Width * Brick_Height; //reset score etc. score = 0; numberOfLives = maxNumberOfLives; player = new Player(new Point((int)gameField.Left, (int)gameField.Bottom - 40)); }
private void NextLevel() { while (Data.NextMaps.Count == 0) Thread.Sleep(100); map = Data.NextMaps.Dequeue(); player = new Player(); camera = new Camera(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); this.camera.Zoom = (float)(Data.Windowsize / 256f); Data.Levels++; }
private void Load() { Data.Load(); ; int blocks = (Data.BlockPerLevel + (Data.Levels / 10) * 25) * Data.Levels; map = new Map(Data.LastSeed, Data.BlockPerLevel + blocks, Data.Levels); Data.NextMaps.Clear(); player = new Player(); camera = new Camera(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); Data.Levels++; }
void HandlePetActionHelper(Unit pet, ObjectGuid guid1, uint spellid, ActiveStates flag, ObjectGuid guid2, float x, float y, float z) { CharmInfo charmInfo = pet.GetCharmInfo(); if (charmInfo == null) { Log.outError(LogFilter.Network, "WorldSession.HandlePetAction(petGuid: {0}, tagGuid: {1}, spellId: {2}, flag: {3}): object (GUID: {4} Entry: {5} TypeId: {6}) is considered pet-like but doesn't have a charminfo!", guid1, guid2, spellid, flag, pet.GetGUID().ToString(), pet.GetEntry(), pet.GetTypeId()); return; } switch (flag) { case ActiveStates.Command: //0x07 switch ((CommandStates)spellid) { case CommandStates.Stay: //flat=1792 //STAY pet.StopMoving(); pet.GetMotionMaster().Clear(false); pet.GetMotionMaster().MoveIdle(); charmInfo.SetCommandState(CommandStates.Stay); charmInfo.SetIsCommandAttack(false); charmInfo.SetIsAtStay(true); charmInfo.SetIsCommandFollow(false); charmInfo.SetIsFollowing(false); charmInfo.SetIsReturning(false); charmInfo.SaveStayPosition(); break; case CommandStates.Follow: //spellid=1792 //FOLLOW pet.AttackStop(); pet.InterruptNonMeleeSpells(false); pet.GetMotionMaster().MoveFollow(GetPlayer(), SharedConst.PetFollowDist, pet.GetFollowAngle()); charmInfo.SetCommandState(CommandStates.Follow); charmInfo.SetIsCommandAttack(false); charmInfo.SetIsAtStay(false); charmInfo.SetIsReturning(true); charmInfo.SetIsCommandFollow(true); charmInfo.SetIsFollowing(false); break; case CommandStates.Attack: //spellid=1792 //ATTACK { // Can't attack if owner is pacified if (GetPlayer().HasAuraType(AuraType.ModPacify)) { // @todo Send proper error message to client return; } // only place where pet can be player Unit TargetUnit = Global.ObjAccessor.GetUnit(GetPlayer(), guid2); if (!TargetUnit) { return; } Unit owner = pet.GetOwner(); if (owner) { if (!owner.IsValidAttackTarget(TargetUnit)) { return; } } pet.ClearUnitState(UnitState.Follow); // This is true if pet has no target or has target but targets differs. if (pet.GetVictim() != TargetUnit || (pet.GetVictim() == TargetUnit && !pet.GetCharmInfo().IsCommandAttack())) { if (pet.GetVictim()) { pet.AttackStop(); } if (!pet.IsTypeId(TypeId.Player) && pet.ToCreature().IsAIEnabled) { charmInfo.SetIsCommandAttack(true); charmInfo.SetIsAtStay(false); charmInfo.SetIsFollowing(false); charmInfo.SetIsCommandFollow(false); charmInfo.SetIsReturning(false); pet.ToCreature().GetAI().AttackStart(TargetUnit); //10% chance to play special pet attack talk, else growl if (pet.IsPet() && pet.ToPet().getPetType() == PetType.Summon && pet != TargetUnit && RandomHelper.IRand(0, 100) < 10) { pet.SendPetTalk(PetTalk.Attack); } else { // 90% chance for pet and 100% chance for charmed creature pet.SendPetAIReaction(guid1); } } else // charmed player { if (pet.GetVictim() && pet.GetVictim() != TargetUnit) { pet.AttackStop(); } charmInfo.SetIsCommandAttack(true); charmInfo.SetIsAtStay(false); charmInfo.SetIsFollowing(false); charmInfo.SetIsCommandFollow(false); charmInfo.SetIsReturning(false); pet.Attack(TargetUnit, true); pet.SendPetAIReaction(guid1); } } break; } case CommandStates.Abandon: // abandon (hunter pet) or dismiss (summoned pet) if (pet.GetCharmerGUID() == GetPlayer().GetGUID()) { GetPlayer().StopCastingCharm(); } else if (pet.GetOwnerGUID() == GetPlayer().GetGUID()) { Cypher.Assert(pet.IsTypeId(TypeId.Unit)); if (pet.IsPet()) { if (pet.ToPet().getPetType() == PetType.Hunter) { GetPlayer().RemovePet(pet.ToPet(), PetSaveMode.AsDeleted); } else { //dismissing a summoned pet is like killing them (this prevents returning a soulshard...) pet.setDeathState(DeathState.Corpse); } } else if (pet.HasUnitTypeMask(UnitTypeMask.Minion)) { ((Minion)pet).UnSummon(); } } break; case CommandStates.MoveTo: pet.StopMoving(); pet.GetMotionMaster().Clear(false); pet.GetMotionMaster().MovePoint(0, x, y, z); charmInfo.SetCommandState(CommandStates.MoveTo); charmInfo.SetIsCommandAttack(false); charmInfo.SetIsAtStay(true); charmInfo.SetIsFollowing(false); charmInfo.SetIsReturning(false); charmInfo.SaveStayPosition(); break; default: Log.outError(LogFilter.Network, "WORLD: unknown PET flag Action {0} and spellid {1}.", flag, spellid); break; } break; case ActiveStates.Reaction: // 0x6 switch ((ReactStates)spellid) { case ReactStates.Passive: //passive pet.AttackStop(); goto case ReactStates.Defensive; case ReactStates.Defensive: //recovery case ReactStates.Aggressive: //activete if (pet.IsTypeId(TypeId.Unit)) { pet.ToCreature().SetReactState((ReactStates)spellid); } break; } break; case ActiveStates.Disabled: // 0x81 spell (disabled), ignore case ActiveStates.Passive: // 0x01 case ActiveStates.Enabled: // 0xC1 spell { Unit unit_target = null; if (!guid2.IsEmpty()) { unit_target = Global.ObjAccessor.GetUnit(GetPlayer(), guid2); } // do not cast unknown spells SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellid); if (spellInfo == null) { Log.outError(LogFilter.Network, "WORLD: unknown PET spell id {0}", spellid); return; } foreach (SpellEffectInfo effect in spellInfo.GetEffectsForDifficulty(Difficulty.None)) { if (effect != null && (effect.TargetA.GetTarget() == Targets.UnitSrcAreaEnemy || effect.TargetA.GetTarget() == Targets.UnitDestAreaEnemy || effect.TargetA.GetTarget() == Targets.DestDynobjEnemy)) { return; } } // do not cast not learned spells if (!pet.HasSpell(spellid) || spellInfo.IsPassive()) { return; } // Clear the flags as if owner clicked 'attack'. AI will reset them // after AttackStart, even if spell failed if (pet.GetCharmInfo() != null) { pet.GetCharmInfo().SetIsAtStay(false); pet.GetCharmInfo().SetIsCommandAttack(true); pet.GetCharmInfo().SetIsReturning(false); pet.GetCharmInfo().SetIsFollowing(false); } Spell spell = new Spell(pet, spellInfo, TriggerCastFlags.None); SpellCastResult result = spell.CheckPetCast(unit_target); //auto turn to target unless possessed if (result == SpellCastResult.UnitNotInfront && !pet.isPossessed() && !pet.IsVehicle()) { Unit unit_target2 = spell.m_targets.GetUnitTarget(); if (unit_target) { pet.SetInFront(unit_target); Player player = unit_target.ToPlayer(); if (player) { pet.SendUpdateToPlayer(player); } } else if (unit_target2) { pet.SetInFront(unit_target2); Player player = unit_target2.ToPlayer(); if (player) { pet.SendUpdateToPlayer(player); } } Unit powner = pet.GetCharmerOrOwner(); if (powner) { Player player = powner.ToPlayer(); if (player) { pet.SendUpdateToPlayer(player); } } result = SpellCastResult.SpellCastOk; } if (result == SpellCastResult.SpellCastOk) { unit_target = spell.m_targets.GetUnitTarget(); //10% chance to play special pet attack talk, else growl //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell if (pet.IsPet() && (pet.ToPet().getPetType() == PetType.Summon) && (pet != unit_target) && (RandomHelper.IRand(0, 100) < 10)) { pet.SendPetTalk(PetTalk.SpecialSpell); } else { pet.SendPetAIReaction(guid1); } if (unit_target && !GetPlayer().IsFriendlyTo(unit_target) && !pet.isPossessed() && !pet.IsVehicle()) { // This is true if pet has no target or has target but targets differs. if (pet.GetVictim() != unit_target) { if (pet.GetVictim()) { pet.AttackStop(); } pet.GetMotionMaster().Clear(); if (pet.ToCreature().IsAIEnabled) { pet.ToCreature().GetAI().AttackStart(unit_target); } } } spell.prepare(spell.m_targets); } else { if (pet.isPossessed() || pet.IsVehicle()) // @todo: confirm this check { Spell.SendCastResult(GetPlayer(), spellInfo, spell.m_SpellVisual, spell.m_castId, result); } else { spell.SendPetCastResult(result); } if (!pet.GetSpellHistory().HasCooldown(spellid)) { pet.GetSpellHistory().ResetCooldown(spellid, true); } spell.finish(false); spell.Dispose(); // reset specific flags in case of spell fail. AI will reset other flags if (pet.GetCharmInfo() != null) { pet.GetCharmInfo().SetIsCommandAttack(false); } } break; } default: Log.outError(LogFilter.Network, "WORLD: unknown PET flag Action {0} and spellid {1}.", flag, spellid); break; } }
private void WeaponAvailableForSell(Player customer) { var listOfWeaponNames = weaponsToSell.Keys.ToList(); var listOfWeaponPrices = weaponsToSell.Values.ToList(); int choice; bool parseSuccessfull; Console.Clear(); Console.WriteLine($"Weapons avaliable for the {customer.FightClass}:"); do { PrintDesign.WriteLineInGreen($"\nGold in wallet: {customer.Gold}"); PrintDesign.PrintShop(weaponsToSell); Console.Write("Number: "); parseSuccessfull = int.TryParse(Console.ReadLine(), out choice); if (choice <= 0) { Console.Clear(); PrintDesign.WriteLineInRed("Chosen number to small!"); } else if (parseSuccessfull == false) { Console.Clear(); PrintDesign.WriteLineInRed("Something went wrong!"); } else if (choice >= 4) { Console.Clear(); PrintDesign.WriteLineInRed("Chosen number to high!"); } } while (choice >= 4 || choice <= 0 || parseSuccessfull == false); if (listOfWeaponPrices[choice - 1] > customer.Gold) { Console.Clear(); PrintDesign.WriteLineInRed($"You dont have enough money to buy {listOfWeaponNames[choice - 1]}!"); } else if (customer.Weapon == listOfWeaponNames[choice - 1]) { Console.Clear(); PrintDesign.WriteLineInRed($"You already own {listOfWeaponNames[choice - 1]}!"); } else { Console.Clear(); PrintDesign.WriteLineInGreen($"\n{listOfWeaponNames[choice - 1]} bought and equipped!"); customer.Weapon = listOfWeaponNames[choice - 1]; customer.Gold -= listOfWeaponPrices[choice - 1]; if (choice == 1) { customer.MaxDmg -= ExtraDamageFromWeapons; ExtraDamageFromWeapons = 3; customer.MaxDmg += ExtraDamageFromWeapons; } if (choice == 2) { customer.MaxDmg -= ExtraDamageFromWeapons; ExtraDamageFromWeapons = 5; customer.MaxDmg += ExtraDamageFromWeapons; } if (choice == 3) { customer.MaxDmg -= ExtraDamageFromWeapons; ExtraDamageFromWeapons = 7; customer.MaxDmg += ExtraDamageFromWeapons; } } }
public virtual void VoluntaryAction(Player p) { }
/// <summary> /// Performs the action. If user has coorect key, opens the door, else - tells him he needs a key. /// </summary> /// <returns> /// The action. /// </returns> /// <param name='p'> /// If set to <c>true</c> p. /// </param> /// <param name='l'> /// If set to <c>true</c> l. /// </param> /// <param name='msg'> /// If set to <c>true</c> message. /// </param> /// <param name='l2'> /// If set to <c>true</c> l2. /// </param> public override IPlace AutomaticAction(Player p) { // this wont happen, every door has a key return this; }
/// <summary> /// Konstruktor ³aduj¹cy zapisan¹ grê /// </summary> /// <param name="form"> WskaŸnik do okna gry</param> /// <param name="player">Instancja gracza</param> /// <param name="game_state_data_to_load">Dane stany gry do ³adowania</param> /// <param name="data_index">Indeks danych w tablicy stanów gry</param> public Game(DungeonVandal.MenuForm form, Player player, GameState.GameStateData game_state_data_to_load, int data_index) { Form = form; graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = Form.ViewportSize.Width, PreferredBackBufferHeight = Form.ViewportSize.Height }; data_to_load = game_state_data_to_load; this.data_index = data_index; this.player = player; this.player.Dynamite = data_to_load.Dynamites[data_index]; this.player.Points = data_to_load.Points[data_index]; this.player.Rackets = data_to_load.Rackets[data_index]; totalMinutes = data_to_load.TotalMinutes[data_index]; totalSeconds = data_to_load.TotalSeconds[data_index]; Form.setPlayerName(player.Name); graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings; System.Windows.Forms.Control.FromHandle(Window.Handle).VisibleChanged += MainGame_VisibleChanged; System.Windows.Forms.Control.FromHandle(Form.Handle).KeyUp += new System.Windows.Forms.KeyEventHandler(Game_KeyUp); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyPress += new System.Windows.Forms.KeyPressEventHandler(Game_KeyPress); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyDown += new System.Windows.Forms.KeyEventHandler(Game_Key); System.Windows.Forms.Control.FromHandle(Form.Handle).PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(Game_PreviewKeyDown); Content.RootDirectory = "Content"; IsMouseVisible = true; }
/// <summary> /// Konstruktor dla nowej gry /// </summary> /// <param name="player">Instancja gracza</param> public void NewGame(Player player) { this.player = player; game_map = new Map.Map(tile_size, map_width, map_height, this.Content, player, Form.ChoosenLevel); music = Content.Load<Song>("Audio\\background_music"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(music); if (!player.AudioSettings.IsMuted) MediaPlayer.Volume = (float)player.AudioSettings.MusicVolume; else MediaPlayer.Volume = 0; Form.setPlayerName(player.Name); graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings; System.Windows.Forms.Control.FromHandle(Window.Handle).VisibleChanged += MainGame_VisibleChanged; System.Windows.Forms.Control.FromHandle(Form.Handle).KeyUp += new System.Windows.Forms.KeyEventHandler(Game_KeyUp); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyPress += new System.Windows.Forms.KeyPressEventHandler(Game_KeyPress); System.Windows.Forms.Control.FromHandle(Form.Handle).KeyDown += new System.Windows.Forms.KeyEventHandler(Game_Key); IsMouseVisible = true; isStarted = true; }