Ejemplo n.º 1
0
 public GameViewModel()
 {
     NewGame(715, 855, false, 500000, 10, 2);
     GameInformation    = "Press any key to start game...";
     _gameObjectHandler = new GameObjectHandler();
     _collisionHandler  = new CollisionHandler();
 }
Ejemplo n.º 2
0
        public override void Init()
        {
            screenHandler.AddScreen(new EnduranceMode(game, screenHandler));

            attachedMode = (EnduranceMode)screenHandler.GetCurrentActiveScreen();

            handler = attachedMode.GetGameObjectHandler();

            playerHealthToDecrease = 0;
            enemyHealthToDecrease  = 0;

            healthP1             = GetHealthOfCharacter("player");
            ammoCountP1          = GetAmmoOfPlayer();
            specialAttackCountP1 = GetSpecialAttackofPlayer();

            playerHealthBarRect     = new Rectangle(70, 20, healthP1 * SCALE, 20);
            playerHealthBarRectBack = playerHealthBarRect;
            playerSpecialRect       = new Rectangle(playerHealthBarRect.X, playerHealthBarRect.Bottom, (int)specialAttackCountP1 * SCALE, 5);
            playerIcon           = GetCharacterIcon("player");
            playerIconRect       = new Rectangle(playerHealthBarRect.X - 50, playerHealthBarRect.Y - 10, 40, 40);
            playerAmmoCountRects = new Rectangle[3];
            for (int i = 0; i < playerAmmoCountRects.Length; i++)
            {
                playerAmmoCountRects[i] = new Rectangle(playerHealthBarRect.X + (i * 35), playerSpecialRect.Bottom, 30, 30);
            }

            enemyHealth            = GetHealthOfCharacter("goblin");
            enemyHealthBarRect     = new Rectangle(game.GraphicsDevice.Viewport.Width - playerHealthBarRect.X - enemyHealth * SCALE, playerHealthBarRect.Y, enemyHealth * SCALE, playerHealthBarRect.Height);
            enemyHealthBarBackRect = enemyHealthBarRect;
            enemyIconRect          = new Rectangle(game.GraphicsDevice.Viewport.Width - playerIconRect.X - playerIconRect.Width, playerIconRect.Y, playerIconRect.Width, playerIconRect.Height);
            enemyIcon = GetCharacterIcon("goblin");
        }
Ejemplo n.º 3
0
 public GameObject(Rectangle _gameObjectRectangle, string _gameObjectTag, GameObjectHandler _hanlder, Game game)
 {
     SetGameObjectRectangle(_gameObjectRectangle);
     SetGameObjectTag(_gameObjectTag);
     SetGameObjectHandler(_hanlder);
     SetGameObjectGame(game);
 }
Ejemplo n.º 4
0
        public override void Init()
        {
            const int FLOORLIMIT   = 480;
            const int PLAYERHEIGHT = 120;
            const int PLAYERWIDTH  = 100;
            const int GOBLINHEIGHT = 120;
            const int GOBLINWIDTH  = 70;
            const int HEALTH       = 100;
            const int PLAYERVELO   = 4;
            const int ENEMYVELO    = 3;

            handler = new GameObjectHandler();

            Rectangle playerRect = new Rectangle(0, FLOORLIMIT - PLAYERHEIGHT, PLAYERWIDTH, PLAYERHEIGHT);
            Spiderman player     = new Spiderman(playerRect, "player", handler, playerAnimations, game, PLAYERVELO, HEALTH, FLOORLIMIT + 1, playerIcon);

            player.SetProjectileTexture(projectileTexture);

            Rectangle   goblinRect = new Rectangle(700, FLOORLIMIT - GOBLINHEIGHT, GOBLINWIDTH, GOBLINHEIGHT);
            GreenGoblin goblin     = new GreenGoblin(goblinRect, "goblin", handler, greenGoblinAnimations, game, ENEMYVELO, HEALTH, FLOORLIMIT + 1, goblinIcon);

            handler.Add(player);
            handler.Add(goblin);

            backgroundContainer = new Rectangle(0, 0, game.GraphicsDevice.Viewport.Width * 2, game.GraphicsDevice.Viewport.Height);
        }
Ejemplo n.º 5
0
 public Projectile(Rectangle _gameObjectRectangle, string _gameObjectTag, GameObjectHandler _hanlder, Game game, float _deathspan, float _velocity, Texture2D _projectileTexture) : base(_gameObjectRectangle, _gameObjectTag, _hanlder, game)
 {
     initalPos.X = gameObjectRectangle.Location.X;
     initalPos.Y = gameObjectRectangle.Location.Y;
     SetupVelocity(_velocity);
     SetLifeSpan(_deathspan);
     SetProjectImg(_projectileTexture);
 }
Ejemplo n.º 6
0
 public Character(Rectangle _gameObjectRectangle, string _gameObjectTag, GameObjectHandler handler, Animation[] _animations, Game game, int _velocity, int _health, int yLimit, Texture2D characterIcon)
     : base(_gameObjectRectangle, _gameObjectTag, handler, game)
 {
     SetCharacterVelocity(_velocity);
     SetCharacterHealth(_health);
     SetCharacterAnimations(_animations);
     SetCharacterYLimit(yLimit);
     SetCharacterIcon(characterIcon);
     animationHandler = new AnimationHandler(animations);
     isDead           = false;
 }
Ejemplo n.º 7
0
    public void SpawnBall()
    {
        //refreshing object reference
        Destroy(GameObject.FindGameObjectWithTag("Ball"));
        GameObjectHandler objhandler = GameObject.FindGameObjectWithTag("Handler").GetComponent <GameObjectHandler>();

        objhandler.RemoveObject("Ball");
        objhandler.InsertObject(GameObject.FindGameObjectWithTag("Handler").GetComponent <GameHandler>().ballPref, "Ball");
        Instantiate <GameObject>(objhandler.ReceiveObject("Ball"), new Vector3(0, 0, 0), Quaternion.identity);
        GameObject.FindGameObjectWithTag("Ball").GetComponent <Ball>().OnDeath += GameObject.FindGameObjectWithTag("Handler").GetComponent <GameHandler>().SpawnBall;
    }
 private void Awake()
 {
     _onLetterAppearance = GetComponent <AudioSource>();
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
    public void CarsOnFastRoad()
    {
        if (MainMenu.playMode == 1)
        {
            numberOfPathsInSingleRoad = ExperimentParameters.lanes_per_direction;
            carObjectHandlerArray     = new GameObjectHandler[3];
            //switch cases
            if (ExperimentParameters.carType != "All")
            {
                switch (ExperimentParameters.carType)
                {
                case "Car":
                    carObjectHandlerArray[0] =
                        new GameObjectHandler(Resources.Load("Prefabs/Car") as GameObject,            //pooling from the prefab with copies that is like the number of paths in each street
                                              ExperimentParameters.numberOfRoads * 10 * 2, true, ""); //making a prefab copy with a number enough to cover a whole one path

                    break;

                case "Truck":
                    carObjectHandlerArray[1] =
                        new GameObjectHandler(Resources.Load("Prefabs/Truck") as GameObject,       //pooling from the prefab with copies that is like the number of paths in each street
                                              numberOfPathsInSingleRoad * 10 * 2, true, "");       //making a prefab copy with a number enough to cover a whole one path

                    break;

                case "Bus":
                    carObjectHandlerArray[2] =
                        new GameObjectHandler(Resources.Load("Prefabs/Bus") as GameObject,       //pooling from the prefab with copies that is like the number of paths in each street
                                              numberOfPathsInSingleRoad * 10 * 2, true, "");     //making a prefab copy with a number enough to cover a whole one path

                    break;
                }
                carObjectHandlerArray[0].DeactivateAll();
            }
            else
            {
                carObjectHandlerArray[0] =
                    new GameObjectHandler(Resources.Load("Prefabs/Car") as GameObject,        //pooling from the prefab with copies that is like the number of paths in each street
                                          ExperimentParameters.numberOfRoads * 10, true, ""); //making a prefab copy with a number enough to cover a whole one path
                carObjectHandlerArray[1] =
                    new GameObjectHandler(Resources.Load("Prefabs/Truck") as GameObject,      //pooling from the prefab with copies that is like the number of paths in each street
                                          ExperimentParameters.numberOfRoads * 10, true, ""); //making a prefab copy with a number enough to cover a whole one path
                carObjectHandlerArray[2] =
                    new GameObjectHandler(Resources.Load("Prefabs/Bus") as GameObject,        //pooling from the prefab with copies that is like the number of paths in each street
                                          ExperimentParameters.numberOfRoads * 10, true, ""); //making a prefab copy with a number enough to cover a whole one path
            }



            InstantiateCarsFastRoad(carObjectHandlerArray);
            //carObjectHandler.DeactivateAll(); //deactivate all the cars after putting every component we want
        }
    }
Ejemplo n.º 10
0
    void Start()
    {
        _input = GameObject.FindGameObjectWithTag("Input").GetComponent <KeyInputManager>();

        _goHandler = GameObject.FindGameObjectWithTag("Handler").GetComponent <GameObjectHandler>();
        _goHandler.InsertObject(GameObject.FindGameObjectWithTag("Player"), "Player");
        _goHandler.InsertObject(GameObject.FindGameObjectWithTag("Cpu"), "Cpu");

        _goHandler.InsertObject(ballPref, "Ball");
        Instantiate <GameObject>(_goHandler.ReceiveObject("Ball"), new Vector3(0, 0, 0), Quaternion.identity);


        GameObject.FindGameObjectWithTag("Ball").GetComponent <Ball>().OnDeath += SpawnBall;

        _input.AddDelicate(MoveTheBall, "Start", KeyInputManager.keyInputType.OnHold);
        _input.AddDelicate(_goHandler.ReceiveObject("Player").GetComponent <PongBar>().MoveUp, "Up", KeyInputManager.keyInputType.OnHold);
        _input.AddDelicate(_goHandler.ReceiveObject("Player").GetComponent <PongBar>().MoveDown, "Down", KeyInputManager.keyInputType.OnHold);
    }
    GameObject InstantiateCarsRightLane(GameObjectHandler carHandler, int index, GameObject parent)
    {
        int   yRotate; //to know the rotation of the car before instantiate
        float carMeasure = 0;

        yRotate = (ExperimentParameters.streetsDirections.Split()[0].Equals("Right")) ? -1 : +1;  //identify the rotation

        /// carMeasure = (sidewalkWidth) + ((index - 1) * ((streetPathWidth))) + ((index - 1) * midwalkWidth) + (streetPathWidth * 3 / 4);
        carMeasure = roadsController.roadsArray[index].transform.position.x + 1.06f;



        GameObject car = carHandler.RetrieveInstance(new Vector3(carMeasure,
                                                                 -2.0f, yRotate * (190.0f + ExperimentParameters.distanceBetweenCars)),
                                                     Quaternion.Euler(new Vector3(0, yRotate * -90, 0)));

        car.AddComponent <CarMove>();                                                                  //adding the CarMove Script
        car.GetComponent <CarMove>().carDirection = ExperimentParameters.streetsDirections.Split()[0]; //describe which direction
        car.transform.parent = parent.transform;                                                       //putting the instantiated car to a parent
        return(car);
    }
Ejemplo n.º 12
0
 public Bomb(Rectangle _gameObjectRectangle, string _gameObjectTag, GameObjectHandler _hanlder, Game game, float _deathspan, float _velocity, Texture2D _projectileTexture, Animation animation) : base(_gameObjectRectangle, _gameObjectTag, _hanlder, game, _deathspan, _velocity, _projectileTexture)
 {
     SetBombAnim(animation);
     damage = 15;
 }
Ejemplo n.º 13
0
 private void Awake()
 {
     i = this;
 }
Ejemplo n.º 14
0
 public Spiderman(Rectangle _gameObjectRectangle, string _gameObjectTag, GameObjectHandler handler, Animation[] _animations, Game game, int _velocity, int _health, int ylimit, Texture2D characterIcon)
     : base(_gameObjectRectangle, _gameObjectTag, handler, _animations, game, _velocity, _health, ylimit, characterIcon)
 {
     Init();
 }
Ejemplo n.º 15
0
 private void SetGameObjectHandler(GameObjectHandler handler)
 {
     this.handler = handler;
 }
Ejemplo n.º 16
0
 public AttackWeb(Rectangle _gameObjectRectangle, string _gameObjectTag, GameObjectHandler _hanlder, Game game, float _deathspan, float _velocity, Texture2D _projectileTexture) : base(_gameObjectRectangle, _gameObjectTag, _hanlder, game, _deathspan, _velocity, _projectileTexture)
 {
     this.rotation = (float)Math.PI / 4;
     damage        = 10;
 }
Ejemplo n.º 17
0
        protected virtual void OnRemoveGameObject(GameObject gameObject)
        {
            GameObjectHandler handler = RemoveGameObject;

            handler?.Invoke(this, new GameObjectEventArgs(gameObject));
        }
Ejemplo n.º 18
0
 public Web(Rectangle _gameObjectRectangle, string _gameObjectTag, GameObjectHandler _hanlder, Game game, float _deathspan, float _velocity, Texture2D _projectileTextures) : base(_gameObjectRectangle, _gameObjectTag, _hanlder, game, _deathspan, _velocity, _projectileTextures)
 {
     pos = new Vector2(initalPos.X, initalPos.Y - projectileTexture.Height);
 }