public void OnLeftButton()
 {
     currentWall--;
     if (currentWall < WALL.Front)
     {
         currentWall = WALL.Left;
     }
     ChangeWall();
 }
 public void OnRightButton()
 {
     currentWall++;
     if (currentWall > WALL.Left)
     {
         currentWall = WALL.Front;
     }
     ChangeWall();
 }
Example #3
0
    public void Init(Sprite bulletSprite, Vector3 startPos, WALL wallHit)
    {
        if(!_init)
        {
            _init = true;
            gameObject.SetActive(true);

            gameObject.transform.position = new Vector3(startPos.x + xOffset(wallHit),startPos.y + yOffset(wallHit),startPos.z);

            int randomBulletHole = Random.Range(1,12);
            this.GetComponent<SpriteRenderer>().sprite = bulletSprite;

            StartCoroutine(erase());
        }
    }
Example #4
0
    private float yOffset(WALL wallHit)
    {
        float yOff;
        if (wallHit == WALL.TOP || wallHit == WALL.BOTTOM)
        {
            yOff = Random.Range(1, 10) * 0.1f;
            if (wallHit == WALL.BOTTOM) yOff *= -1;
        }
        else
        {
            yOff = Random.Range(1, 3) * 0.1f;
            if (Random.Range(0, 1) == 1) yOff *= -1;
        }

        return yOff;
    }
Example #5
0
    private float xOffset(WALL wallHit)
    {
        float xOff;
        if(wallHit == WALL.LEFT || wallHit == WALL.RIGHT)
        {
            xOff = Random.Range(1, 10)*0.1f;
            if (wallHit == WALL.LEFT) xOff *= -1;
        }
        else
        {
            xOff = Random.Range(1, 3) * 0.1f;
            if (Random.Range(0, 1) == 1) xOff *= -1;
        }

        return xOff;
    }
Example #6
0
    void Update()
    {
        nbOnWall    = GetComponent <GameManager>().MexicansOnWall();
        nbInCountry = GetComponent <GameManager>().MexicansFree();
        wScale      = WALL.GetComponent <Wall>().WallScale();

        nbWall.GetComponent <Text>().text = nbOnWall.ToString();
        nbFree.GetComponent <Text>().text = nbInCountry.ToString();

        if (Pourcentage(wScale) >= 100.0f)
        {
            wallBuilt.GetComponent <Text>().text = "100%";
        }
        else
        {
            wallBuilt.GetComponent <Text>().text = Pourcentage(wScale).ToString() + "%";
        }
    }
Example #7
0
        public void addHotSpot(int coordX, int coordY, WALL wall, float scale, HotSpot.ClickEventHandler handler)
        {
            listaHotSpot.Add(new HotSpot());

            listaHotSpot[listaHotSpot.Count - 1].ClickEvent = handler;
            listaHotSpot[listaHotSpot.Count - 1].Scale = Matrix.CreateScale(scale);
            listaHotSpot[listaHotSpot.Count - 1].Position = new Vector3((float)coordX, (float)coordY, -4.99f);
            //calcular posicion y rotacion segun la pared donde este
            float rotation = 0.0f;
            switch(wall)
            {
                case WALL.EAST:
                    rotation = MathHelper.PiOver2;
                    break;
                case WALL.NORTH:
                    rotation = 0.0f;
                    break;
                case WALL.WEST:
                    rotation = -MathHelper.PiOver2;
                    break;
                case WALL.SOUTH:
                    rotation = MathHelper.Pi;
                    break;
            }

            listaHotSpot[listaHotSpot.Count - 1].Rotation = Matrix.CreateRotationY(rotation);
        }
Example #8
0
        public void addGoTo(int coordX, int coordY, WALL wall, float scale, string destinyName, GoTo.ClickGoToHandler handler)
        {
            listaGoTo.Add(new GoTo());

            listaGoTo[listaGoTo.Count - 1].DestinyName = destinyName;
            listaGoTo[listaGoTo.Count - 1].GoToEvent = handler;
            listaGoTo[listaGoTo.Count - 1].Scale = Matrix.CreateScale(scale);

            //calcular posicion y rotacion segun la pared donde este
            //mapeando las coordenadas indicadas en la textura
            float antiClippingOffset = 0.01f;
            float rotation = 0.0f;
            float x = 0.0f, y = 0.0f, z = 0.0f;

            faces[(int)wall].LoadContent();
            float imageWidth = faces[(int)wall].Texture.Width;
            float imageHeight = faces[(int)wall].Texture.Height;
            faces[(int)wall].UnloadContent();

            float wallWidth = faces[(int)wall].Ancho;
            float wallHeight = faces[(int)wall].Alto;
            float desp = faces[(int)wall].Ancho / 2;
            switch (wall)
            {
                case WALL.EAST:
                    rotation = -MathHelper.PiOver2;
                    x = desp - antiClippingOffset;
                    y = (2 * (coordY / imageHeight) - 1) * (-wallHeight / 2);
                    z = (2 * (coordX / imageWidth) - 1) * (wallWidth / 2);
                    break;
                case WALL.NORTH:
                    rotation = 0.0f;
                    x = (2 * (coordX / imageWidth) - 1) * (wallWidth / 2);
                    y = (2 * (coordY / imageHeight) - 1) * (-wallHeight / 2);
                    z = -desp + antiClippingOffset;
                    break;
                case WALL.WEST:
                    rotation = MathHelper.PiOver2;
                    x = -desp + antiClippingOffset;
                    y = (2 * (coordY / imageHeight) - 1) * (-wallHeight / 2);
                    z = (2 * (coordX / imageWidth) - 1) * (-wallWidth / 2);
                    break;
                case WALL.SOUTH:
                    rotation = MathHelper.Pi;
                    x = (2 * (coordX / imageWidth) - 1) * (-wallWidth / 2);
                    y = (2 * (coordY / imageHeight) - 1) * (-wallHeight / 2);
                    z = desp - antiClippingOffset;
                    break;
            }
            listaGoTo[listaGoTo.Count - 1].Rotation = Matrix.CreateRotationY(rotation);
            listaGoTo[listaGoTo.Count - 1].Position = new Vector3(x,y,z);
        }
Example #9
0
            public Tile(TILE type, float x, float y, WALL wall)
            {
                this.type = type;
                this.wall = wall;

                switch (type)
                {
                    case TILE.floor:
                        anim = Animation.createSingleFrameAnimation("tiles/floor", new Vector2(x, y), 0.1f);
                        break;
                    case TILE.wall:
                        switch (wall)
                        {
                            case WALL.bounce: anim = Animation.createSingleFrameAnimation("tiles/stickwall", new Vector2(x, y), 0.1f); break;
                            case WALL.destr: anim = Animation.createSingleFrameAnimation("tiles/breakwall", new Vector2(x, y), 0.1f); break;
                            case WALL.pass: anim = Animation.createSingleFrameAnimation("tiles/passwall", new Vector2(x, y), 1.0f); break;
                            default: anim = Animation.createSingleFrameAnimation("tiles/wall", new Vector2(x, y), 0.1f); break;
                        }
                        break;
                }
            }