protected override void Initialize() { m_Enemies = new Enemies(this); m_Barriers = new Barriers(this, k_NumOfBarriers); try { m_Player1 = new Player(1, this); m_Player1.Initialize(); m_Player2 = new Player(2, this); m_Player2.Initialize(); } catch (Exception e) { Console.WriteLine(e); } m_MotherShip = new MotherShip(this); m_CountEnemyKills = 0; m_Graphics.PreferredBackBufferWidth = 750; m_Graphics.PreferredBackBufferHeight = 600; m_Graphics.ApplyChanges(); base.Initialize(); }
public Collosion(Barriers barriers, Player player, Moneys moneys, Modifiers modifiers, List <PlayerBackground> backgrounds) { this.Barriers = barriers; this.Player = player; this.Moneys = moneys; this.Modifiers = modifiers; this.Backgrounds = backgrounds; this.R = new Random(); }
private bool CheckCell(ItemType itemType, Point currentPoint) { var result = Barriers.FirstOrDefault(i => (i.Position.X == currentPoint.X && i.Position.Y == currentPoint.Y)); if (itemType != ItemType.Bullet) { var result2 = DammageableBarriers.FirstOrDefault(i => (i.Position.X == currentPoint.X && i.Position.Y == currentPoint.Y)); var result3 = Waters.FirstOrDefault(i => (i.Position.X == currentPoint.X && i.Position.Y == currentPoint.Y)); return(result == null && result2 == null && result3 == null); } return(result == null); }
void both() { // Записываем цвет в который окрашен игрок в переменую colorPlayer Color colorPlayer = player.GetComponent <Renderer>().material.GetColor("_Color"); // Игрок окрашивает в выбраный объект player.GetComponent <Renderer>().material.color = listBarriers[0].GetComponent <Renderer>().material.GetColor("_Color"); // В цикле перекрашиваем все выбраные объекты в цвет игрока foreach (GameObject Barriers in listBarriers) { Barriers.GetComponent <Renderer>().material.color = colorPlayer; } }
// Use this for initialization void Start() { locX = (int)transform.position.x; locY = (int)(transform.position.y - 1); startX = locX; startY = locY; currentDir = startDir; eventHandler = GetComponent <EventHandler>(); animationHandler = GetComponent <AnimationHandler>(); tiles = grid.GetComponent <SolidTiles>(); barriers = grid.GetComponent <Barriers>(); entities = grid.GetComponent <Entities>(); UpdateEntities(); }
private void initLevelDetails() { Background background = new Background(m_Game, this); SpaceshipPlayers players = new SpaceshipPlayers(m_Game, this); this.Add(players); MotherShip motherShip = new MotherShip(m_Game, this); Enemies enemies = new Enemies(this, m_Game); this.Add(enemies); int numOfBarriers = 4; Barriers barriers = new Barriers(this, m_Game, numOfBarriers); this.Add(barriers); m_PlayersManager = Game.Services.GetService(typeof(IPlayersManager)) as IPlayersManager; m_PlayersManager.GameOverEvent += onGameOver; m_PlayersManager.LevelWonEvent += onLevelWon; }
public PlayScreen(Game i_Game, GameState i_GameState = null) : base(i_Game) { Background background = new Background(this.Game, this); m_GameSettings = (this.Game.Services.GetService(typeof(IGameSettings)) as SpaceInvadersSettings); if (m_GameSettings == null) { m_GameSettings = new SpaceInvadersSettings(this.Game); } setGameState(i_GameState, m_GameSettings); createPlayersAndScoreManagers(); m_Enemies = new EnemiesGroup(this.Game, this); m_Barriers = new Barriers(this.Game, this); m_MotherSpaceship = new MotherShip(this.Game, this); m_MotherShipRandomNotifier = new RandomActionComponent(); m_MotherShipRandomNotifier.RandomTimeAchieved += motherShipRandomNotifier_GoMotherSpaceship; }
void GenerateBarriers() { float z, len; z = fstarLen; while (true) { len = Random.Range(fminLen, fmaxLen); z += len; if (z > mapLen) { break; } Vector3 setposition = getTargetPot(z); int index = Random.Range(0, barriers.Length); Barriers bar = (GameObject.Instantiate(barriers[index]) as Barriers); bar.initSelf(setposition, this.transform); // GenerateBarriers(setposition); } }
protected override void MakeBarriers(SequenceSource seqSource) { StandardBarrierData data = Ability.ModdedBarrierData(); BarrierPayload payload = new BarrierPayload(); payload.OnEnemyHit = delegate(Barrier barrier) { payload.RemoveAtTurnEnd = true; }; payload.GetTechPointsForCaster = barrier => Ability.GetBaseTechPointInteractions(); foreach (Vector3 facingDir in new List <Vector3>() { new Vector3(0, 0, 1), new Vector3(1, 0, 0) }) { var barrier = Utils.ConsBarrier(m_caster, data, m_targetPos, facingDir, seqSource, Ability.ModdedBarrierSequencePrefab()); Barriers.Add(barrier); ArtemisServerBarrierManager.Get().SetBarrierPayload(barrier, payload); } }
void Start() { Player = GameObject.FindGameObjectWithTag("Player"); Barriers = this.GetComponent <Barriers>(); Last = new GameObject("Last"); Inside = new GameObject("Inside"); Next = new GameObject("Next"); GameObject TempObj = Instantiate(boxes[0], new Vector3(-15, -15, -15), Quaternion.identity) as GameObject; xBound = TempObj.GetComponent <MeshRenderer>().bounds.size.x; yBound = TempObj.GetComponent <MeshRenderer>().bounds.size.y; zBound = TempObj.GetComponent <MeshRenderer>().bounds.size.z; Destroy(TempObj); zFinal = 0.0f; hightBoxesCollection = hight * zBound; dTimeToExchangeStyle = Time.time; style = new int[] { 0, 1, 2, 3, 4, 1, 0 }; SetStyle(style, false); }
public Game1() { //NOTE: Init graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime = TimeSpan.FromTicks(333333); // Extend battery life under lock. this.Deactivated += Game1_Deactivated; InactiveSleepTime = TimeSpan.FromSeconds(1); graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft; graphics.IsFullScreen = true; graphics.PreferredBackBufferHeight = 480; graphics.PreferredBackBufferWidth = 800; Consts.PhoneWidth = graphics.PreferredBackBufferWidth; Consts.PhoneHeight = graphics.PreferredBackBufferHeight; firstEntry = true; gameState = GameState.InMainMenu; //NOTE: MENU mainButtons = new List <MenuButton>(); mainButtons.Add(new MenuButton("Main_Start", Consts.P_StartButton, (Consts.PhoneWidth / 2) + 20, (Consts.PhoneHeight / 2) - 220)); mainButtons.Add(new MenuButton("Main_Help", Consts.P_HelpButton, (Consts.PhoneWidth / 2) + 20, (Consts.PhoneHeight / 2) - 220 + 100)); mainButtons.Add(new MenuButton("Main_About", Consts.P_AboutButton, (Consts.PhoneWidth / 2) + 20, (Consts.PhoneHeight / 2) - 220 + 200)); mainButtons.Add(new MenuButton("Main_Vibrate", Consts.P_VibrateButton, (Consts.PhoneWidth) - 100, (Consts.PhoneHeight) - 100)); mainMenu = new Menu(mainButtons); pauseButtons = new List <MenuButton>(); pauseButtons.Add(new MenuButton("Pause_Resume", Consts.P_ResumeButton, (Consts.PhoneWidth / 2) - 166, (Consts.PhoneHeight / 2) - 200)); pauseMenu = new Menu(pauseButtons); tutorialButtons = new List <MenuButton>(); tutorialButtons.Add(new MenuButton("Tutorial", Consts.P_Tutorial, 0, 0)); tutorialMenu = new Menu(tutorialButtons); aboutButtons = new List <MenuButton>(); aboutButtons.Add(new MenuButton("About_Rate", Consts.P_RateButton, (Consts.PhoneWidth / 2) - 166, (Consts.PhoneHeight / 2) - 50)); aboutMenu = new Menu(aboutButtons); //NOTE: GAMING player = new Player("Player1", 4, 100, 340, Consts.P_Player, 1); backBackground = new PlayerBackground(Consts.P_Backgrond, 1); foreBackground = new PlayerBackground(Consts.P_ForeBackground, 2); walkPlace = new PlayerBackground(Consts.P_Walkplace, 4); string level = LevelHelper.SelectLevel(); barriers = new Barriers(level, 4); moneys = new Moneys(level, 4); modifiers = new Modifiers(level, 4); backgroundList = new List <PlayerBackground>(); backgroundList.Add(backBackground); backgroundList.Add(foreBackground); backgroundList.Add(walkPlace); collosion = new Collosion(barriers, player, moneys, modifiers, backgroundList); if (!MenuHelper.FirstStart()) { gameState = GameState.InTutorial; } }
protected override void Update(GameTime gameTime) { switch (gameState) { //NOTE: LOAD LEVEL case GameState.LoadLevel: if (firstEntry) { player.RePosition(); firstEntry = false; Thread loadThread = new Thread(() => { foreach (PlayerBackground item in backgroundList) { item.RePosition(); } string level = LevelHelper.SelectLevel(); barriers = new Barriers(level, 4); barriers.Load(this); moneys = new Moneys(level, 4); moneys.Load(this); modifiers = new Modifiers(level, 4); modifiers.Load(this); collosion = new Collosion(barriers, player, moneys, modifiers, backgroundList); collosion.Load(this); gameState = GameState.Gaming; //Transitions.ChangeGameState(ref firstEntry); }); loadThread.Start(); } player.Update(this, ref firstEntry); backBackground.Scroll(this); foreBackground.Scroll(this); walkPlace.Scroll(this); break; //NOTE: GAMING case GameState.Gaming: if (firstEntry) { firstEntry = false; } else { if (LevelHelper.IsLevelEnd(moneys)) { player.isEnd = true; if (player.Position.X >= Consts.PhoneWidth) { Transitions.ChangeGameState(ref firstEntry); gameState = GameState.InEndGameMenu; } } player.Update(this, ref firstEntry); backBackground.Scroll(this); foreBackground.Scroll(this); walkPlace.Scroll(this); barriers.Scroll(this); moneys.Scroll(this); modifiers.Scroll(this); collosion.Update(); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { gameState = GameState.InPauseMenu; firstEntry = true; } } break; //NOTE: MAIN MENU case GameState.InMainMenu: if (firstEntry) { player.Score.LoadTotalScore(); player.Score.LoadHighScore(); mainMenu = new Menu(mainButtons); player.isDead = false; player.isEatMoney = false; player.isEatModifier = false; backBackground.RePosition(); foreBackground.RePosition(); walkPlace.RePosition(); collosion.Reset(); firstEntry = false; } backBackground.Scroll(this); foreBackground.Scroll(this); walkPlace.Scroll(this); gameState = mainMenu.IsTouched(this, TouchPanel.GetState(), gameState, ref firstEntry); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } break; //NOTE: PAUSE MENU case GameState.InPauseMenu: if (firstEntry) { pauseMenu = new Menu(pauseButtons); firstEntry = false; } gameState = pauseMenu.IsTouched(this, TouchPanel.GetState(), gameState, ref firstEntry); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Transitions.ChangeGameState(ref firstEntry); player.Score.GameScore = 0; gameState = GameState.InMainMenu; } break; //NOTE: TUTORIAL case GameState.InTutorial: backBackground.Scroll(this); foreBackground.Scroll(this); walkPlace.Scroll(this); gameState = tutorialMenu.IsTouched(this, TouchPanel.GetState(), gameState, ref firstEntry); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Transitions.ChangeGameState(ref firstEntry); gameState = GameState.InMainMenu; } break; //NOTE: ABOUT case GameState.About: backBackground.Scroll(this); foreBackground.Scroll(this); walkPlace.Scroll(this); gameState = aboutMenu.IsTouched(this, TouchPanel.GetState(), gameState, ref firstEntry); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Transitions.ChangeGameState(ref firstEntry); gameState = GameState.InMainMenu; } break; //NOTE: ENDGAME MENU case GameState.InEndGameMenu: player.Score.SaveTotalScore(); player.Score.SaveHighScore(); gameState = GameState.InMainMenu; break; default: break; } base.Update(gameTime); }
public void addBarriers() { m_Barriers = new Barriers(this, @"Sprites/Barrier_44x32", m_CurrentLevel); }
/// <summary> /// Populates the loop information. /// </summary> /// <param name="program">The given program.</param> private static void PopulateLoopInformation(Program program) { ProgramGraph graph = new ProgramGraph(program); BackEdges = graph.BackEdges; LoopBarriers = new Dictionary <BackEdge, List <Barrier> >(); foreach (BackEdge edge in graph.BackEdges) { List <ProgramNode> loopNodes = graph.GetLoopNodes(edge); List <Block> loopBlocks = loopNodes.Select(x => x.Block).ToList(); IEnumerable <Barrier> barriers = Barriers.Values.Where(x => loopBlocks.Contains(x.Block)); LoopBarriers.Add(edge, barriers.ToList()); } foreach (Barrier barrier in Barriers.Values) { barrier.LoopDepth = LoopBarriers.Where(x => x.Value.Contains(barrier)).Count(); } // consider barriers instrumented in the header node as a part of the loop // these barriers will not have a loop depth since they are outside the loop foreach (BackEdge edge in graph.BackEdges) { foreach (ProgramNode predecessor in edge.Destination.Predecessors) { // ignore the other end of the back-edge if (predecessor == edge.Source) { continue; } // identify the last thread-level and grid-level barrier in the predecessor int?thread = null, grid = null; int location = predecessor.Block.Cmds.Count - 1; while (location >= 0) { if (predecessor.Block.Cmds[location] is CallCmd) { CallCmd command = predecessor.Block.Cmds[location] as CallCmd; if (thread == null && command.callee.Contains("$bugle_barrier")) { thread = location; } if (grid == null && command.callee.Contains("bugle_grid_barrier")) { grid = location; } } if (thread != null && grid != null) { break; } location = location - 1; } if (thread != null) { CallCmd command = predecessor.Block.Cmds[thread.Value] as CallCmd; Barrier barrier = Barriers.Where(x => x.Value.Call == command).Select(x => x.Value).FirstOrDefault(); if (barrier != null && !LoopBarriers[edge].Contains(barrier)) { LoopBarriers[edge].Add(barrier); } } if (grid != null) { CallCmd command = predecessor.Block.Cmds[grid.Value] as CallCmd; Barrier barrier = Barriers.Where(x => x.Value.Call == command).Select(x => x.Value).FirstOrDefault(); if (barrier != null && !LoopBarriers[edge].Contains(barrier)) { LoopBarriers[edge].Add(barrier); } } } } }
void Start() { Player = GameObject.FindGameObjectWithTag("Player") ; Barriers = this.GetComponent<Barriers>(); Last = new GameObject("Last"); Inside = new GameObject("Inside"); Next = new GameObject("Next"); GameObject TempObj = Instantiate(boxes[0], new Vector3 (-15, -15, -15), Quaternion.identity) as GameObject; xBound = TempObj.GetComponent<MeshRenderer>().bounds.size.x; yBound = TempObj.GetComponent<MeshRenderer>().bounds.size.y; zBound = TempObj.GetComponent<MeshRenderer>().bounds.size.z; Destroy(TempObj); zFinal = 0.0f; hightBoxesCollection = hight * zBound; dTimeToExchangeStyle = Time.time; style = new int[]{0, 1, 2, 3, 4, 1, 0}; SetStyle (style, false); }