public Player(Game game, PlayerIndex id, bool bUsingKeyboard) : base(game) { this.mIsUsingKeyboard = bUsingKeyboard; this.m_id = id; int iPlayerFrameRate = Config.Instance.GetAsInt("PlayerFrameRate"); switch (id) { case PlayerIndex.One: { this.m_idleFrontAnim = new AnimatedSprite(Game, new Vector2(0, 0), 0, mScale.X, 0, "\\player01\\idle\\p1_idle", 8, iPlayerFrameRate); this.m_runAnim = new AnimatedSprite(Game, new Vector2(0, 0), 0, mScale.X, 0, "\\player01\\run\\p1_run", 8, iPlayerFrameRate); break; } case PlayerIndex.Two: { this.m_idleFrontAnim = new AnimatedSprite(Game, new Vector2(0, 0), 0, mScale.X, 0, "\\player02\\idle\\p2_idle", 8, iPlayerFrameRate); this.m_runAnim = new AnimatedSprite(Game, new Vector2(0, 0), 0, mScale.X, 0, "\\player02\\run\\p2_run", 8, iPlayerFrameRate); break; } case PlayerIndex.Three: { this.m_idleFrontAnim = new AnimatedSprite(Game, new Vector2(0, 0), 0, mScale.X, 0, "\\player03\\idle\\p3_idle", 8, iPlayerFrameRate); this.m_runAnim = new AnimatedSprite(Game, new Vector2(0, 0), 0, mScale.X, 0, "\\player03\\run\\p3_run", 8, iPlayerFrameRate); break; } case PlayerIndex.Four: { this.m_idleFrontAnim = new AnimatedSprite(Game, new Vector2(0, 0), 0, mScale.X, 0, "\\player04\\idle\\p4_idle", 8, iPlayerFrameRate); this.m_runAnim = new AnimatedSprite(Game, new Vector2(0, 0), 0, mScale.X, 0, "\\player04\\run\\p4_run", 8, iPlayerFrameRate); break; } } if (Player.m_mergeMonsterAnim == null) Player.m_mergeMonsterAnim = new AnimatedSprite(Game, new Vector2(0, 0), 0, mScale.X, 0, "\\mergemonster\\mm_run", 8, iPlayerFrameRate); }
protected override void LoadContent() { base.LoadContent(); // init scale Random random = new Random((int)DateTime.Now.Ticks); Player smallestPlayer = Program.Instance.GetSmallestPlayer(); Enemy smallestEnemy = Program.Instance.GetSmallestEnemy(); Player largestPlayer = Program.Instance.GetLargestPlayer(); Enemy largestEnemy = Program.Instance.GetLargestEnemy(); int helplessCount = GetHelplessEnemyCount(); if (smallestEnemy == null) { mScale.X = mPixelScale * random.Next((int)(smallestPlayer.PixelWidth * 0.5f), (int)(largestPlayer.PixelWidth * 2.0f)); } else if (helplessCount < Program.Instance.mEnemies.Count * mMinHelpless) { mScale.X = mPixelScale * random.Next(16, (int)smallestPlayer.PixelWidth); } else if (largestEnemy.PixelWidth < largestPlayer.PixelWidth) { mScale.X = mPixelScale * random.Next((int)largestPlayer.PixelWidth, (int)(largestPlayer.PixelWidth * 2.0f)); } else { mScale.X = mPixelScale * random.Next((int)(smallestPlayer.PixelWidth * 0.5f), (int)(largestPlayer.PixelWidth * 2.0f)); } mScale.Y = mScale.X; //this.mBounds = // new BoundingSphere //( // new Vector3(this.mPosition.X, this.mPosition.Y, 0), // this.Radius //); this.SetBboxPos(this.mPosition); GetNewTarget(); mMaxSpeed = 4000f / PixelWidth; // init position switch (random.Next(1, 5)) { case 1: // left { mPositionX = -Radius; mPositionY = random.Next(0, Config.Instance.GetAsInt("ScreenHeight")); break; } case 2: // top { mPositionX = random.Next(0, Config.Instance.GetAsInt("ScreenWidth")); mPositionY = -Radius; break; } case 3: // right { mPositionX = Config.Instance.GetAsInt("ScreenWidth") + Radius; mPositionY = random.Next(0, Config.Instance.GetAsInt("ScreenHeight")); break; } case 4: // bottom { mPositionX = random.Next(0, Config.Instance.GetAsInt("ScreenWidth")); mPositionY = Config.Instance.GetAsInt("ScreenHeight") + Radius; break; } } int iPlayerFrameRate = Config.Instance.GetAsInt("PlayerFrameRate"); mAttackSide = new AnimatedSprite(Game, new Vector2(), 0, mScale.X/2, 0, "\\enemy\\AttackSide\\enemyattack", 8, iPlayerFrameRate); mRunSide = new AnimatedSprite(Game, new Vector2(), 0, mScale.X/2, 0, "\\enemy\\RunSide\\enemyrunside", 8, iPlayerFrameRate); }