Exemplo n.º 1
0
    public void Setup(bool same)
    {
        if (!same)  //If new map
        {
            map = new GameMap();
            map.Start();
        }
        endGame = false;    //setup
        wump    = new Wumpus();
        player  = new Player();
        bats    = new Bat();

        wump.room   = map.getWump();
        player.room = map.getCurrent();
        int[] temp = map.getAdjacent(player.room);
        doors[0] = GameObject.Find("Left Door");
        doors[1] = GameObject.Find("Middle Door");
        doors[2] = GameObject.Find("Right Door");
        for (int i = 0; i < 3; i++)
        {
            doors[i].GetComponent <Door>().doorNum = temp[i];
        }
        bats.room       = map.getBat();
        currentNum.text = "Current Room: " + player.room;
        //GameObject[] doors = FindObjectsOfType(typeof(Door)) as GameObject[];
        for (int i = 0; i < 20; i++)
        {
            rooms[i] = GameObject.Find("/Rooms/Room (" + i + ")");
        }
        Warnings(); //check for initial warnings
    }
Exemplo n.º 2
0
    public void SetValueB()
    {
        Bat bat = new Bat();

        bat.SetValueA();
        B = bat.A;
    }
Exemplo n.º 3
0
        public override void MapLoaded(TeeEngine engine, TiledMap map, MapEventArgs mapEventArgs)
        {
            LightShader lightShader = (LightShader)engine.GetPostGameShader("LightShader");

            lightShader.Enabled = false;

            Random random = new Random();

            for (int i = 0; i < 50; i++)
            {
                int px = (int)Math.Ceiling(random.NextDouble() * engine.Map.pxWidth);
                int py = (int)Math.Ceiling(random.NextDouble() * engine.Map.pxHeight);

                Bat  bat  = new Bat(px, py);
                Coin coin = new Coin(px, py, 100, (CoinType)random.Next(3));

                // Switch between adding bats and coins to the map.
                if (i % 2 == 0)
                {
                    engine.AddEntity(bat);
                }
                else
                {
                    engine.AddEntity(coin);
                }
            }

            base.MapLoaded(engine, map, mapEventArgs);
        }
Exemplo n.º 4
0
    public void Setup(bool same)
    {
        if (!same)  //If new map
        {
            map = new GameMap();
            map.Start();
        }
        endGame = false;    //setup
        wump = new Wumpus();
        player = new Player();
        bats = new Bat();

        wump.room = map.getWump();
        player.room = map.getCurrent();
        int[] temp = map.getAdjacent(player.room);
        doors[0] = GameObject.Find("Left Door");
        doors[1] = GameObject.Find("Middle Door");
        doors[2] = GameObject.Find("Right Door");
        for (int i = 0; i < 3; i++)
        {
            doors[i].GetComponent<Door>().doorNum = temp[i];
        }
        bats.room = map.getBat();
        currentNum.text = "Current Room: " + player.room;
        //GameObject[] doors = FindObjectsOfType(typeof(Door)) as GameObject[];
        for (int i = 0; i < 20; i++)
        {
            rooms[i] = GameObject.Find("/Rooms/Room (" + i + ")");
        }
        Warnings(); //check for initial warnings
    }
Exemplo n.º 5
0
        /// <summary>
        /// Moves to the next floor of the dungeon
        /// </summary>
        public void NextFloor()
        {
            //this.gameObjects.RemoveAll(x => x.IsEnemy); // remove everything except the player

            /*Bat bat = new Bat();
             *
             * bat.Transform.Position = new Vector2(0, 0);
             * bat.Load();
             * this.AddGameObject(bat);*/

            // the enemies to spawn
            var enemiesSpawning   = new int[] { 1, 2 };
            var maxEnemiesToSpawn = 3;

            player.Reset();

            Random r = new Random();

            for (int i = 0; i < 10; i++)
            {
                var rand = r.Next(0, 100);
                if (rand <= 25)
                {
                    Bat bat = new Bat();
                    bat.Transform.Position = new Vector2(r.Next(200, 1000), r.Next(100, 600));
                    bat.Load();
                    this.AddGameObject(bat);
                }
            }

            // load the scene again
            SceneManager.StartingNewCombatScene = true;
        }
Exemplo n.º 6
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (!bat && other.tag == "SpawnDetector")
     {
         bat = GetComponentInParent <BatSpawner>().Spawn(transform);
     }
 }
Exemplo n.º 7
0
 public void ValidDestinyPosition(Position source, Position destiny)
 {
     if (!Bat.piece(source).PossibleMovement(destiny))
     {
         throw new BattlefieldlException("Invalid Destiny Position.");
     }
 }
Exemplo n.º 8
0
        public void Start()
        {
            leftWall  = new Wall(1, Constant.pnlH / 2, 2, Constant.pnlH - 4);
            topWall   = new Wall(Constant.pnlW / 2, 1, Constant.pnlW - 4, 2);
            rightWall = new Wall(Constant.pnlW - 1, Constant.pnlH / 2, 2, Constant.pnlH - 4);
            bat       = new Bat();
            ball      = new Ball();
            {
                double i = 4, j = 4;
                while (true)
                {
                    bricks.Add(new Brick(i + Brick.Width / 2, j + Brick.Height / 2));
                    i += Brick.Width + 2;
                    if (i >= Constant.pnlW)
                    {
                        i  = 4;
                        j += Brick.Height + 2;
                        if (j >= Constant.pnlH - 200)
                        {
                            break;
                        }
                    }
                }
            }
            Physic.Init();

            GameControl.Start();
        }
Exemplo n.º 9
0
    void OnCollisionEnter(Collision collision)
    {
        //if hit by bat
        Bat bat = collision.gameObject.GetComponentInParent <Bat>();

        if (bat)
        {
            //save start position
            previousPosition = transform.position;

            //and start coroutine
            if (addPoints_Coroutine != null)
            {
                StopCoroutine(addPoints_Coroutine);
            }

            addPoints_Coroutine = StartCoroutine(AddPoints_Coroutine());
        }
        //if not hit bat
        else
        {
            //stop coroutine because reached the destination
            if (addPoints_Coroutine != null)
            {
                StopCoroutine(addPoints_Coroutine);
            }
        }
    }
Exemplo n.º 10
0
 private void Awake()
 {
     player      = GameObject.FindGameObjectWithTag("Player");
     meleeAttack = player.GetComponent <MeleeAttack>();
     bat         = GetComponentInParent <Bat>();
     rb          = GetComponentInParent <Rigidbody2D>();
 }
Exemplo n.º 11
0
    public void spawnBat()
    {
        GameObject newBat    = Instantiate(bat, new Vector2(transform.position.x, transform.position.y), Quaternion.identity);
        Bat        batScript = newBat.GetComponent <Bat>();

        batScript.facingRight = facingRight;
    }
Exemplo n.º 12
0
        Monster CreateRandomMonster(Vector2 location)
        {
            Monster monster = null;

            if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Bat))
            {
                monster = new Bat(new Vector2());
            }
            else if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Ghost))
            {
                monster = new Ghost(new Vector2());
            }
            else if (CanHazMonster(Settings.Monsters.BigSlime))
            {
                monster = new BigSlime(new Vector2(), GetSlimeLevel());
            }
            else if (CanHazMonster(Settings.Monsters.Grub))
            {
                monster = new Grub(new Vector2(), true);
            }
            else if (CanHazMonster(Settings.Monsters.Fly))
            {
                monster = new Fly(new Vector2(), true);
            }
            else if (CanHazMonster(Settings.Monsters.Brute))
            {
                monster = new ShadowBrute(new Vector2());
            }
            else if (CanHazMonster(Settings.Monsters.Golem))
            {
                monster = new RockGolem(new Vector2(), deepWoods.GetCombatLevel());
            }
            else if (CanHazMonster(Settings.Monsters.RockCrab))
            {
                monster = new RockCrab(new Vector2(), GetRockCrabType());
            }
            else
            {
                foreach (var modMonster in DeepWoodsAPI.ToShuffledList(ModEntry.GetAPI().Monsters))
                {
                    if (modMonster.Item1(deepWoods, location))
                    {
                        monster = modMonster.Item2();
                        break;
                    }
                }
                if (monster == null)
                {
                    monster = new GreenSlime(new Vector2(), GetSlimeLevel());
                }
            }

            if (deepWoods.level.Value >= Settings.Level.MinLevelForBuffedMonsters && !this.random.CheckChance(Settings.Monsters.ChanceForUnbuffedMonster))
            {
                BuffMonster(monster);
            }

            return(monster);
        }
Exemplo n.º 13
0
 void Awake()
 {
     // Set up the references.
     jumpTimer    = jumpTimerMax;
     player       = GameObject.FindGameObjectWithTag("Player").transform;
     playerHealth = player.GetComponent <PlayerStats> ();
     enemy        = GetComponent <Bat> ();
 }
Exemplo n.º 14
0
 void Start()
 {
     script = GetComponentInParent <Bat>();
     script.OnAttack.AddListener(Attacking);
     anim       = GetComponent <Animator>();
     anim.speed = 2.55f;
     speed      = anim.speed;
 }
Exemplo n.º 15
0
    public void Die()
    {
        Destroy(gameObject);
        GameObject bat_black = GameObject.Find("bat_black");
        Bat        bat       = bat_black.GetComponent <Bat>();

        bat.SpawnBall();
    }
Exemplo n.º 16
0
 private void Awake()
 {
     panel     = FindObjectOfType <Panel>();
     rigidbody = GetComponent <Rigidbody2D>();
     //animator = GetComponent<Animator>();
     sprite = GetComponentInChildren <SpriteRenderer>();
     balls  = Resources.Load <Balls>("Ball");
     bat    = Resources.Load <Bat>("Bat");
 }
Exemplo n.º 17
0
    private void Attack()
    {
        Vector3 position = transform.position;

        position.x += 1F * (sprite.flipX ? -1.0F : 1.0F);
        Bat newbat = Instantiate(bat, position, bat.transform.rotation) as Bat;

        newbat.Parent = gameObject;
    }
Exemplo n.º 18
0
        public override bool[,] PossiblesMovements()
        {
            bool[,] mat = new bool[Bat.Line, Bat.Collum];

            Position position = new Position(0, 0);

            //NO
            position.SetValues(position.Line - 1, position.Collum - 1);
            while (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
                if (Bat.piece(position) != null && Bat.piece(position).color != color)
                {
                    break;
                }
                position.SetValues(position.Line - 1, position.Collum - 1);
            }

            //NE
            position.SetValues(position.Line - 1, position.Collum + 1);
            while (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
                if (Bat.piece(position) != null && Bat.piece(position).color != color)
                {
                    break;
                }
                position.SetValues(position.Line - 1, position.Collum + 1);
            }

            //SE
            position.SetValues(position.Line + 1, position.Collum + 1);
            while (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
                if (Bat.piece(position) != null && Bat.piece(position).color != color)
                {
                    break;
                }
                position.SetValues(position.Line + 1, position.Collum + 1);
            }

            //SO
            position.SetValues(position.Line + 1, position.Collum - 1);
            while (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
                if (Bat.piece(position) != null && Bat.piece(position).color != color)
                {
                    break;
                }
                position.SetValues(position.Line + 1, position.Collum - 1);
            }

            return(mat);
        }
Exemplo n.º 19
0
        public override bool[,] PossiblesMovements()
        {
            bool[,] mat = new bool[Bat.Line, Bat.Collum];

            Position position = new Position(0, 0);

            position.SetValues(position.Line - 1, position.Collum - 2);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line - 2, position.Collum - 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line - 2, position.Collum + 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line - 1, position.Collum + 2);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line + 1, position.Collum + 2);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line + 2, position.Collum + 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line + 2, position.Collum - 1);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            position.SetValues(position.Line + 1, position.Collum - 2);
            if (Bat.ValidPosition(position) && CanMove(position))
            {
                mat[position.Line, position.Collum] = true;
            }

            return(mat);
        }
Exemplo n.º 20
0
        public void CanOverrideMethods()
        {
            //IsNocturnal is defined in the Mammal class
            //Both Batty and Doggo have the property,
            //but it's set to different values b/c both have overriden it
            BuildAZoo.Classes.Lactating.Mammal.Mammal2Leg.Bat Batty = new Bat();
            BuildAZoo.Classes.Lactating.Mammal.Mammal4Leg.Dog Doggo = new Dog();

            Assert.NotEqual(Batty.IsNocturnal, Doggo.IsNocturnal);
        }
Exemplo n.º 21
0
        public void Update(float elapsed)
        {
            _intervalTimer += elapsed;
            if (_isOn == false || _intervalTimer < SpawnInterval || !EnemySpawnList.Any())
                return;
            _intervalTimer = 0;

            Bat enemy = new Bat(EnemySpawnList[_rnd.Next(0, EnemySpawnList.Count - 1)], Bloodbender.ptr.player);
            Bloodbender.ptr.listGraphicObj.Add(enemy);
        }
Exemplo n.º 22
0
 protected void Init(Bat prefab)
 {
     for (int i = 0; i < _capacity; i++)
     {
         Bat spawned = Instantiate(prefab, transform);
         spawned.Dying += OnSpawnedDyed;
         spawned.gameObject.SetActive(false);
         _pool.Add(spawned);
     }
 }
    public void _on_Timer_timeout()
    {
        Bat  bat      = packedBatObject.Instance() as Bat;
        Node batLayer = GetNode("/root/World/YSort");

        batLayer.AddChild(bat);
        bat.GlobalPosition = this.GlobalPosition;
        bat.setHomePosition(bat.GlobalPosition);
        timer.Start(spawnTimer);
    }
Exemplo n.º 24
0
    void CreateBat(Bat batPrefab)
    {
        //create and set start position
        Bat bat = Instantiate(batPrefab, transform.position, Quaternion.identity);

        bat.GetComponent <Rigidbody>().position = transform.position;

        //set current bat
        batsToSwing = bat;
    }
Exemplo n.º 25
0
        public static LivingBeing InitializeBat(Map m, Vector2 v)
        {
            var b = new Bat(m.Game, v);

            RegisterActions(b);

            m.fullBoard.Add(b);
            b.IsUserControlled = false;
            return(b);
        }
Exemplo n.º 26
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            batLeft = new Bat(10,10,1,Content.Load<Texture2D>("bat"));
            batRight = new Bat(760, 10, 2, Content.Load<Texture2D>("bat"));
            ball = new Ball(400, 240, 150, 175, Content.Load<Texture2D>("ball"), Content.Load<SpriteFont>("Font"));
        }
Exemplo n.º 27
0
        public Piece ExecuteMovement(Position source, Position destiny)
        {
            Piece piece = Bat.RemovePiece(source);

            piece.ToIncreaseMovement();
            Piece capturedPiece = Bat.RemovePiece(destiny);

            Bat.PuttPiece(piece, destiny);
            if (capturedPiece != null)
            {
                captureds.Add(capturedPiece);
            }

            //Especia play Little Roque
            if (piece is King && destiny.Collum == source.Collum + 2)
            {
                Position sourceT  = new Position(source.Line, source.Collum + 3);
                Position destinyT = new Position(source.Line, source.Collum + 1);
                Piece    T        = Bat.RemovePiece(sourceT);
                T.ToIncreaseMovement();
                Bat.PuttPiece(T, destinyT);
            }

            //Especial Play Big Roque
            if (piece is King && destiny.Collum == source.Collum - 2)
            {
                Position sourceT  = new Position(source.Line, source.Collum - 4);
                Position destinyT = new Position(source.Line, source.Collum - 1);
                Piece    T        = Bat.RemovePiece(sourceT);
                T.ToIncreaseMovement();
                Bat.PuttPiece(T, destinyT);
            }

            //Especial Play En Passant
            if (piece is Pawn)
            {
                if (source.Collum != destiny.Collum && capturedPiece == null)
                {
                    Position posP;
                    if (piece.color == Color.White)
                    {
                        posP = new Position(destiny.Line + 1, destiny.Collum);
                    }
                    else
                    {
                        posP = new Position(destiny.Line - 1, destiny.Collum);
                    }
                    capturedPiece = Bat.RemovePiece(posP);
                    captureds.Add(capturedPiece);
                }
            }

            return(capturedPiece);
        }
Exemplo n.º 28
0
    public void Add(GameObject _object, Vector3 _position, Quaternion _rotation, bool _isHost, float _angle)
    {
        Bat bat = new Bat();

        bat = PhotonNetwork.Instantiate(_object.name, _position, _rotation).AddComponent <Bat>() as Bat;
        bat.Init(_isHost, _angle);
        #region EVENT_LISTENER_ADD_Bat
        bat.GetComponent <Bat>().EVENT_REMOVE += Remove;
        #endregion EVENT_LISTENER_ADD_Bat
        listOfObjetFactories.Add(bat);
    }
Exemplo n.º 29
0
    void OnCollisionEnter2D()
    {
        BonusSpawn();
        Destroy(gameObject);
        GameManagerScript.Cur_Bricks--;
        GameManagerScript.Score += 1;
        GameObject bat_black = GameObject.Find("bat_black");
        Bat        bat       = bat_black.GetComponent <Bat>();

        bat.ballForce += 1;
    }
Exemplo n.º 30
0
 // Use this for initialization
 void Start()
 {
     for (int i = 0; i < BatsCount; i++)
     {
         GameObject currentBat       = Instantiate(BatPrefab);
         Bat        currentBatScript = currentBat.GetComponent <Bat> ();
         currentBatScript.BatSpeed   = BatSpeed;
         currentBat.transform.parent = this.gameObject.transform;
         CurrentsBats.Add(currentBat);
     }
 }
Exemplo n.º 31
0
    public void DisableSuperSkill()
    {
        isUsingSuperFlight = false;
        isUsingSuperSpeed  = false;
        isUsingSuperTime   = false;

        // Remove the superskill trail
        TrailRenderer trailRenderer = gameObject.GetComponentInChildren <TrailRenderer>();

        trailRenderer.enabled = false;

        // Reset gravity to its orignal value
        gameObject.GetComponent <Rigidbody2D>().gravityScale = oriGravityScale;
        PteraMover.DeactivateTimeFreeze();
        CaveFlamePit.DeactivateTimeFreeze();
        Fireball.DeactivateTimeFreeze();
        DestroyByTime.DeactivateTimeFreeze();
        LaserBeam.DeactivateTimeFreeze();
        Saw.DeactivateTimeFreeze();
        LaserTurret.DeactivateTimeFreeze();
        Bat.DeactivateTimeFreeze();
        SwingingBoulder[] sb = FindObjectsOfType <SwingingBoulder>();
        sb[0].DeactivateTimeFreeze();
        sb[1].DeactivateTimeFreeze();
        sb[2].DeactivateTimeFreeze();
        sb[3].DeactivateTimeFreeze();
        sb[4].DeactivateTimeFreeze();
        sb[5].DeactivateTimeFreeze();
        sb[6].DeactivateTimeFreeze();
        RockController.DeactivateTimeFreeze();
        Turret.DeactivateTimeFreeze();
        PlayerController[] players = FindObjectsOfType <PlayerController>();
        foreach (PlayerController p in players)
        {
            p.timeFreezeActivated = false;
            p.GetComponent <Rigidbody2D>().isKinematic = false;
            p.anim.enabled = true;
        }
        GameObject[] FXs = GameObject.FindGameObjectsWithTag("FX");
        foreach (GameObject fx in FXs)
        {
            fx.GetComponent <ParticleSystem>().Play();
        }
        Arrow.DeactivateTimeFreeze();
        Puma.DeactivateTimeFreeze();
        Piranha.DeactivateTimeFreeze();
        Cobra.DeactivateTimeFreeze();
        Saw.DeactivateTimeFreeze();
        Banana.DeactivateTimeFreeze();
        BananaSpawn[] bs = FindObjectsOfType <BananaSpawn>();
        bs[0].DeactivateTimeFreeze();
        bs[1].DeactivateTimeFreeze();
        bs[2].DeactivateTimeFreeze();
    }
Exemplo n.º 32
0
 private void OnEnable()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         Instance = this;
     }
 }
Exemplo n.º 33
0
        public void testHasOccupantType()
        {
            Wumpus wumpus = new Wumpus("Wumpy", rooms[0]);
            Bat bat = new Bat("Batty", rooms[4] );
            Player player1 = new Player("Marie", rooms[1]);

            foreach (Room room in rooms)
            {
                if (room.hasOccupantType(EntityType.wumpus))
                    Console.WriteLine("Room " + room.id + " has a wumpus");
                if (room.hasOccupantType(EntityType.bat))
                    Console.WriteLine("Room " + room.id + " has a bat");
                if (room.hasOccupantType(EntityType.pit))
                    Console.WriteLine("Room " + room.id + " has a pit");
                if (room.hasOccupantType(EntityType.player))
                    Console.WriteLine("Room " + room.id + " has a player");
                if (room.hasOccupantType(EntityType.arrow))
                    Console.WriteLine("Room " + room.id + " has an arrow");
            }
        }
Exemplo n.º 34
0
    public void Setup(bool same)
    {
        if (!same)  //If new map
        {
            map = new GameMap();
            map.Start();
        }
        endGame = false;    //setup
        wump = new Wumpus();
        player = new Player();
        bats = new Bat();

        wump.room = map.getWump();
        player.room = map.getCurrent();
        bats.room = map.getBat();
        for (int i = 0; i < 20; i++)
        {
            rooms[i] = GameObject.Find("Room (" + i + ")");
            rooms[i].GetComponent<Room>().player = false;
        }
        Warnings(); //check for initial warnings
        rooms[player.room].GetComponent<Room>().player = true;     //show player room
    }
Exemplo n.º 35
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            content = new ContentManager(Services);

            //graphics.SynchronizeWithVerticalRetrace = false;

            gameState = new GameState();

            //Create the bat Sprites - they need the keyboard controls and the gameplay area limits
            _player1 = new Bat(30, Keys.Q, Keys.A, 0, Window.ClientBounds.Height);

            //use this line for a second human player
            //_player2 = new Bat( ClientSize.Width - 30 - Bat.Width, Keys.P, Keys.L, 0, ClientSize.Height);

            //use this line for a computer player
            _player2 = new Bat(Window.ClientBounds.Width - 30 - Bat.Width, 0, Window.ClientBounds.Height);

            //Create the ball sprite. It needs the gameplay area limits and references to the bats to be able to check for collisions
            _ball = new Ball(0, Window.ClientBounds.Width, 0, Window.ClientBounds.Height, _player1, _player2, gameState);

            //Connect the AI player with the ball
            _player2.Ball = _ball;
        }
Exemplo n.º 36
0
 private int CheckHitLocation(Bat bat)
 {
     int block = 0;
     if (ball.GetPosition().Y < bat.GetPosition().Y + bat.GetSize().Height / 20) block = 1;
     else if (ball.GetPosition().Y < bat.GetPosition().Y + bat.GetSize().Height / 10 * 2) block = 2;
     else if (ball.GetPosition().Y < bat.GetPosition().Y + bat.GetSize().Height / 10 * 3) block = 3;
     else if (ball.GetPosition().Y < bat.GetPosition().Y + bat.GetSize().Height / 10 * 4) block = 4;
     else if (ball.GetPosition().Y < bat.GetPosition().Y + bat.GetSize().Height / 10 * 5) block = 5;
     else if (ball.GetPosition().Y < bat.GetPosition().Y + bat.GetSize().Height / 10 * 6) block = 6;
     else if (ball.GetPosition().Y < bat.GetPosition().Y + bat.GetSize().Height / 10 * 7) block = 7;
     else if (ball.GetPosition().Y < bat.GetPosition().Y + bat.GetSize().Height / 10 * 8) block = 8;
     else if (ball.GetPosition().Y < bat.GetPosition().Y + bat.GetSize().Height / 20 * 19) block = 9;
     else block = 10;
     return block;
 }
Exemplo n.º 37
0
 private void SetUpSingle()
 {
     rightBat = new AIBat(Content, new Vector2(screenWidth, screenHeight), false);
     leftBat = new Bat(Content, new Vector2(screenWidth, screenHeight), true);
 }
Exemplo n.º 38
0
 void Start()
 {
     body = GetComponent<Bat>();
     walkTimer = Random.Range (0, 3.0f);
 }
Exemplo n.º 39
0
 public void SetBat(Bat bat)
 {
     bat.Init(new Bat.BatCallback(OnBallInPlay));
 }
Exemplo n.º 40
0
    void Start()
    {
        hazard_cap = 2;
        wumpusCave = new Cave();
        player = new Player("Hunter");
        wumpus = new Wumpus("Wumpy");
        bats = new List<Bat>(hazard_cap);
        pits = new List<Pit>(hazard_cap);

           //init bats & pits
           for (int i = 0; i < hazard_cap; i++ ){
           Bat bat = new Bat(i.ToString());
           bats.Add(bat);
           Pit pit = new Pit(i);
           pits.Add(pit);
            }

           positions = new int[6];
           setup(1);

           //assign player references to controllers
           //*I don't like it but I run into Object reference not set to an instance errors otherwise..
           inputController = GetComponent<InputController>();
           guiController =  GameObject.Find("Canvas").GetComponent<GUIController>();
           imgController = GetComponent<ImagePlaneController>();
           inputController.player = player;
           guiController.player = player;
           guiController.gameState = STATE;

           //assign Room prefabs to a room DAO
           Transform Rooms = GameObject.Find("WumpusCave/Rooms").GetComponent<Transform>();
           UnityEngine.Debug.Log(Rooms.childCount);
           for(int i = 0; i < Rooms.childCount; i++)
           Rooms.GetChild(i).GetComponent<RoomBehavior>().room = wumpusCave.rooms[i];
    }
Exemplo n.º 41
0
 void Start()
 {
     batScript = GetComponent<Bat>();
 }
Exemplo n.º 42
0
    // Use this for initialization
    void Start()
    {
        layer = Camera.main.GetComponent<GUILayer>();

        ballScript = gameBall.GetComponent<Ball>();

        batScript = batObj.GetComponent<Bat>();

        //Debug.Log("Screen Resolution " + Screen.width + " " + Screen.height);
    }
Exemplo n.º 43
0
    // set info,map,player,enemy
    public void NewLevel(int level)
    {
        switch (level)
        {
            case 1:
            {
                InfoBox.Info("\n\n***** Welcome to Level 1 ***** \n"
                              +"The bats move randomly,\n"
                              +" and would attack you when they get nearby.\n"
                              +"Press '2' to get your Bow and clear them all!");
                map=new Map();

                Player.weaponGet[2] = true;
                player=new Player();
                player.SetPlace(map);
                player.weapon = new BareHand();

                cntEnemy=5;
                enemy=new Enemy[cntEnemy];
                for (int i=0;i<cntEnemy;++i)
                {
                    enemy[i]=new Bat();
                    enemy[i].SetPlace(map);
                }
                break;
            }
            case 2:
            {
                InfoBox.Info("\n\n***** Welcome to Level 2 ***** \n"
                              + "You've got a new Sword\n"
                              + " which is very powerful !\n"
                              + "Well... Just enjoy it!");
                map = new Map();

           //     Player.weaponGet[1] = true;
                player = new Player();
                player.SetPlace(map);
                player.ChangeWeapon(1);

                cntEnemy = 20;
                enemy = new Enemy[cntEnemy];
                for (int i = 0; i < cntEnemy; ++i)
                {
                    enemy[i] = new Bat();
                    enemy[i].SetPlace(map);
                }
                break;
            }
            case 3:
            {
                InfoBox.Info("\n\n***** Welcome to Level 3 ***** \n"
                              + "Cautious!\n"
                              + "The Ghoul looks hungry..\n"
                              + "Are you brave enough to face them ?!");
                map = new Map();

                player = new Player();
                player.SetPlace(map);
                player.ChangeWeapon(1);

                cntEnemy = 10;
                enemy = new Enemy[cntEnemy];
                int i;
                for (i = 0; i < 2; ++i)
                {
                    enemy[i] = new Ghoul();
                    enemy[i].SetPlace(map);
                }
                for (; i < cntEnemy; ++i)
                {
                    enemy[i] = new Bat();
                    enemy[i].SetPlace(map);
                }
                break;
            }
            case 4:
            {
                InfoBox.Info("\n\n***** Welcome to Level 4 ***** \n"
                              + "More Ghouls..\n"
                              + "But you've got a Mace!\n"
                              + "Clear everything nearby!");
                map = new Map();

             //   Player.weaponGet[3] = true;
                player = new Player();
                player.SetPlace(map);
                player.ChangeWeapon(3);

                cntEnemy = 15;
                enemy = new Enemy[cntEnemy];
                int i;
                for (i = 0; i < 4; ++i)
                {
                    enemy[i] = new Ghoul();
                    enemy[i].SetPlace(map);
                }
                for (; i < cntEnemy; ++i)
                {
                    enemy[i] = new Bat();
                    enemy[i].SetPlace(map);
                }
                break;
            }
            case 5:
            {
                InfoBox.Info("\n\n***** Welcome to Level 5 ***** \n"
                              + "What's that?\n"
                              + "A wonderful Shield!\n"
                              + "It'd defend the bats perfectly! ");
                map = new Map();

            //    Player.weaponGet[4] = true;
                player = new Player();
                player.SetPlace(map);
                player.ChangeWeapon(4);

                cntEnemy = 20;
                enemy = new Enemy[cntEnemy];
                int i;
                for (i = 0; i < 5; ++i)
                {
                    enemy[i] = new Ghoul();
                    enemy[i].SetPlace(map);
                }
                for (; i < cntEnemy; ++i)
                {
                    enemy[i] = new Bat();
                    enemy[i].SetPlace(map);
                }
                break;
            }
        }
        //		map.Show();
    }
Exemplo n.º 44
0
 public void testBatMove()
 {
     Bat bat = new Bat("Batty", rooms[0]);
     bat.movePlayer(player, rooms);
 }
Exemplo n.º 45
0
 public void testSense()
 {
     Wumpus  wumpus  = new Wumpus("Wumpy", rooms[1]);   //put him in a room next to player
     Bat     bat     = new Bat("Batty", rooms[4]);
     player.sense();
 }