Пример #1
0
        public override void Update(GameTime gametime, mainGame game)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                game.Exit();
            }


            if (player1.rectangleSprite.Intersects(ground.rectangleSprite))
            {
                player1.positionSprite.Y = player1.positionSprite.Y - 10;

                player1.Timer = 5f;
            }
            if (player2.rectangleSprite.Intersects(ground.rectangleSprite))
            {
                player2.positionSprite.Y = player2.positionSprite.Y - 10;

                player2.Timer = 5f;
            }
            if (player1.rectangleSprite.Intersects(basicEnemy.rectangleSprite))
            {
                player1.Visible = false;
            }
            if (player2.rectangleSprite.Intersects(basicEnemy.rectangleSprite))
            {
                player2.Visible = false;
            }

            basicEnemy.Update(gametime);
            player1.Update(gametime);
            player2.Update(gametime);
            base.Update(gametime, game);
        }
Пример #2
0
    public Camera myCam; // The camera object

    // Use this for initialization
    void Start()
    {
        gameMgr = GameObject.Find("GameObject").GetComponent <gameManager>();
        main    = GameObject.Find("Main Camera").GetComponent <mainGame>();
        PID     = gameMgr.honeyCount++;
        myCam   = GameObject.Find("Main Camera").GetComponent <Camera>();
    }
Пример #3
0
 public override void Update(GameTime gametime, mainGame game)
 {
     keyState = Keyboard.GetState();
     if (keyState.IsKeyDown(Keys.Enter))
     {
         ScreenManager.Instance.AddScreen(new GameScreen(), game);
     }
     base.Update(gametime, game);
 }
Пример #4
0
    void Start()
    {
        player     = GameObject.Find("Wang");
        mainCamera = GameObject.Find("Main Camera");
        locRot     = new Quaternion(0, 0.707f, 0, 0.707f);
        debugText  = GameObject.Find("VRRotationText").GetComponent <Text>();

        gameHandler = GameObject.Find("GameHandler");
        mainScript  = gameHandler.GetComponent <mainGame>();
    }
Пример #5
0
        public override void Draw(SpriteBatch spriteBatch, Rectangle dimensions, mainGame game)
        {
            mainBackGround.Draw(spriteBatch);
            ground.Draw(spriteBatch);

            basicEnemy.Draw(spriteBatch);
            player1.Draw(spriteBatch);
            player2.Draw(spriteBatch);
            base.Draw(spriteBatch, dimensions, game);
        }
Пример #6
0
        public override void Initialize(mainGame game)
        {
            player1    = new Player1(game);
            player2    = new Player2(game);
            basicEnemy = new BasicEnemy(game);

            mainBackGround = new Background(game);
            ground         = new Plateform(game);

            base.Initialize(game);
        }
Пример #7
0
 // Use this for initialization
 void Start()
 {
     CameraMovement     = Camera.main.GetComponent <CameraMovement>();
     mainGame           = GameObject.Find("mainGame").GetComponent <mainGame>(); //fixme:應該減少使用GameObject.find
     SelectBoxTransform = transform.Find("SelectBox");
     HighlightsFX       = Camera.main.GetComponent <HighlightsFX>();
     Depth       = Camera.main.farClipPlane;
     IsDragModel = false;
     if (IsPcControl)
     {
         IsDragModel = true;
     }
     SelectBoxInitialize();
     SelectFrameInitialize();
 }
Пример #8
0
        public override void LoadContent(ContentManager Content, mainGame game)
        {
            Texture2D player1Texture  = Content.Load <Texture2D>("sprites/feu");
            Vector2   player1Position = new Vector2(0, game.GraphicsDevice.Viewport.Height - 300);

            player1.ReverseSprite = Content.Load <Texture2D>("sprites/feuInverse");

            Texture2D player2Texture  = Content.Load <Texture2D>("sprites/glace");
            Vector2   player2Position = new Vector2(0, game.GraphicsDevice.Viewport.Height - 300);

            player2.ReverseSprite = Content.Load <Texture2D>("sprites/glaceInverse");

            Vector2   enemyPosition       = new Vector2(game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height - 120);
            Texture2D enemyTexture1       = Content.Load <Texture2D>("sprites/insecteVertInverse");
            Texture2D ReverseSpriteEnemy1 = Content.Load <Texture2D>("sprites/insecteVert");

            Texture2D enemyTexture2       = Content.Load <Texture2D>("sprites/insecteRoseInverse");
            Texture2D ReverseSpriteEnemy2 = Content.Load <Texture2D>("sprites/insecteRose");

            Texture2D enemyTexture3       = Content.Load <Texture2D>("sprites/insecteBleuInverse");
            Texture2D ReverseSpriteEnemy3 = Content.Load <Texture2D>("sprites/insecteBleu");

            basicEnemy.DictionarySpritesEnemy.Add(enemyTexture1, ReverseSpriteEnemy1);
            basicEnemy.DictionarySpritesEnemy.Add(enemyTexture2, ReverseSpriteEnemy2);
            basicEnemy.DictionarySpritesEnemy.Add(enemyTexture3, ReverseSpriteEnemy3);


            Texture2D mainbackgroundTexture = Content.Load <Texture2D>("backgrounds/volcan");

            mainBackGround.rectangleSprite = new Rectangle(0, 0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height);

            Texture2D groundTexture = Content.Load <Texture2D>("textures/sol");

            ground.rectangleSprite = new Rectangle(-10, game.GraphicsDevice.Viewport.Height - 93, game.GraphicsDevice.Viewport.Width + 10, 300);

            // TODO: use this.Content to load your game content here
            mainBackGround.Initialize(mainbackgroundTexture);
            ground.Initialize(groundTexture);

            player1.Initialize(player1Texture, player1Position);
            player2.Initialize(player2Texture, player2Position);
            basicEnemy.Initialize(enemyPosition);

            base.LoadContent(Content, game);
        }
Пример #9
0
	void Awake()
	{
		controllerScript = GameObject.FindGameObjectWithTag("Scene Controller").GetComponent<mainGame>();
	}
Пример #10
0
    void Awake()
    {
        controllerScript = GameObject.FindGameObjectWithTag("Scene Controller").GetComponent <mainGame>();

        hatCollider = this.gameObject.GetComponent <BoxCollider2D>();
    }
Пример #11
0
    // Update is called once per frame, this will not be used for this project as far as my knowledge
    void Update()
    {
        // Spawn Car
        timer -= Time.deltaTime;
        // If game is started and car spawn timer is < 0 car will spawn
        if (gameIsStarted)
        {
            main = GameObject.Find("Main Camera").GetComponent <mainGame>();
        }

        if (timer < 0 && gameIsStarted)
        {
            //reset timer, random type, and spawn car
            timer         = UnityEngine.Random.Range(3, 9);
            carType       = UnityEngine.Random.Range(0, 8);
            carStartIndex = UnityEngine.Random.Range(0, 3);
            Instantiate(Resources.Load(carPrefabDict[carType]) as GameObject, carStartPosArray[carStartIndex], Quaternion.identity);
            count++;
        }



        // This checks if the loaded level is 4, which should be tutorial 01
        if (Application.loadedLevel == 4)
        {
            // Variables that will get the buildings from the map
            GameObject obj = GameObject.FindGameObjectWithTag("school");
            school = obj.GetComponent <Building>();

            obj      = GameObject.FindGameObjectWithTag("Hospatal");
            Hospatal = obj.GetComponent <Building>();

            obj  = GameObject.FindGameObjectWithTag("Bank");
            Bank = obj.GetComponent <Building>();

            obj           = GameObject.FindGameObjectWithTag("Police_station");
            PoliceStation = obj.GetComponent <Building>();

            obj   = GameObject.FindGameObjectWithTag("Building2");
            store = obj.GetComponent <Building>();

            obj   = GameObject.FindGameObjectWithTag("House");
            House = obj.GetComponent <Building>();

            obj    = GameObject.FindGameObjectWithTag("Petrol");
            Petrol = obj.GetComponent <Building>();

            if (userFound)
            {
                print("Working");
                loadSave();
                userFound = false;
            }

            if (school.life == 0 && Hospatal.life == 0 && Bank.life == 0 && PoliceStation.life == 0 && store.life == 0 && House.life == 0 && Petrol.life == 0)
            {
                print("GameOver");
                gameOver       = true;
                Time.timeScale = 0;
            }

            if (cash < 0)
            {
                print("GameOver");
                gameOver       = true;
                Time.timeScale = 0;
            }

            if (cash >= 5000)
            {
                print("Winner");
                gameWin = true;
            }
        }
    }
Пример #12
0
 public GameEventSystem(mainGame PBDGame) : base(PBDGame)
 {
     Initialize();
 }
Пример #13
0
 void Awake()
 {
     controllerScript = GameObject.FindGameObjectWithTag("Scene Controller").GetComponent <mainGame>();
 }
Пример #14
0
 public override void LoadContent(ContentManager Content, mainGame game)
 {
     base.LoadContent(Content, game);
     background = Content.Load <Texture2D>("backgrounds/TitleScreen");
 }
Пример #15
0
 public virtual void Draw(SpriteBatch spriteBatch, Rectangle dimensions, mainGame game)
 {
 }
Пример #16
0
 public virtual void Update(GameTime gametime, mainGame game)
 {
 }
Пример #17
0
 public virtual void LoadContent(ContentManager Content, mainGame game)
 {
     content = new ContentManager(Content.ServiceProvider, "Content");
 }
Пример #18
0
 public virtual void Initialize(mainGame game)
 {
 }
Пример #19
0
 public override void Draw(SpriteBatch spriteBatch, Rectangle dimensions, mainGame game)
 {
     spriteBatch.Draw(background, dimensions, Color.White);
     base.Draw(spriteBatch, dimensions, game);
 }
Пример #20
0
	void Awake () 
	{
		controllerScript = GameObject.FindGameObjectWithTag("Scene Controller").GetComponent<mainGame>();

		hatCollider = this.gameObject.GetComponent<BoxCollider2D>();
	}
Пример #21
0
 public Player1(mainGame game) : base(game)
 {
 }
Пример #22
0
 public IGameSystem(mainGame mainGame)
 {
     this.mainGame = mainGame;
 }