Beispiel #1
0
 void Start()
 {
     attacking  = true;
     samurai    = GetComponentInChildren <SamuraiBehaviour>();
     player     = GameObject.FindGameObjectWithTag("Players");
     playerData = player.GetComponent <Player>();
 }
 // Start is called before the first frame update
 void Start()
 {
     speed        = 100;
     samurai      = GetComponentInChildren <SamuraiBehaviour>();
     samuraiAStar = GetComponent <AstarSamurai>();
     rb           = GetComponent <Rigidbody2D>();
 }
Beispiel #3
0
    private void createEnemies(int[] coordinates)
    {
        //ENEMIGOS SERPIENTE
        for (int obj = 0; obj < numEneF_cel; obj++)
        {
            rand1    = rand.GetInt(1, width - 1);
            rand2    = rand.GetInt(1, height - 1);
            position = new Vector3Int(rand1, rand2, 0);


            if (tilemap_obj.HasTile(position) == false)
            {
                if (coordinates[0] != 0 || coordinates[1] != 0)
                {
                    position = translatePositiontoWorldCell(coordinates, position);
                    Vector3 tilePos = tilemap_obj.CellToWorld(position);

                    if (spawnPositions != null)
                    {
                        if (!spawnPositions.Contains(position))
                        {
                            Instantiate <GameObject>(enemy_follow, tilePos, Quaternion.identity);
                            spawnPositions.Add(position);
                        }
                    }
                    else
                    {
                        Instantiate <GameObject>(enemy_follow, tilePos, Quaternion.identity);
                        spawnPositions.Add(position);
                    }
                }
                else
                {
                }
            }
        }

        //ENEMIGOS DISPARADORES
        for (int obj = 0; obj < numEneS_cel; obj++)
        {
            rand1 = rand.GetInt(1, width - 1);
            rand2 = rand.GetInt(1, height - 1);
            Vector3Int positionShooter = new Vector3Int(rand1, rand2, 0);


            if (tilemap_obj.HasTile(positionShooter) == false && coordinates[0] != 0 || coordinates[1] != 0)
            {
                positionShooter = translatePositiontoWorldCell(coordinates, positionShooter);
                Vector3 tilePos = tilemap_obj.CellToWorld(positionShooter);
                //tilemap_obj.GetSprite(positionShooter);

                if (spawnPositions != null)
                {
                    if (!spawnPositions.Contains(positionShooter))
                    {
                        Instantiate <GameObject>(enemy_shooter, tilePos, Quaternion.identity);
                        spawnPositions.Add(positionShooter);
                    }
                }
                else
                {
                    Instantiate <GameObject>(enemy_shooter, tilePos, Quaternion.identity);
                    spawnPositions.Add(positionShooter);
                }
            }
            else
            {
            }
        }


        //ENEMIGOS SAMURAI
        for (int obj = 0; obj < numEneSam_cel; obj++)
        {
            rand1    = rand.GetInt(1, width - 1);
            rand2    = rand.GetInt(1, height - 1);
            position = new Vector3Int(rand1, rand2, 0);


            if (tilemap_obj.HasTile(position) == false)
            {
                if (coordinates[0] != 0 || coordinates[1] != 0)
                {
                    position = translatePositiontoWorldCell(coordinates, position);
                    Vector3 tilePos = tilemap_obj.CellToWorld(position);

                    //Cogemos coordenadas de la primera puerta de la sala
                    Vector3Int positionDoor1 = translatePositiontoWorldCell(coordinates, new Vector3Int(5, 9, 0));
                    Vector3    Door1Pos      = tilemap_obj.CellToWorld(positionDoor1);

                    //Cogemos coordenadas de la segunda puerta de la sala
                    Vector3Int positionDoor2 = translatePositiontoWorldCell(coordinates, new Vector3Int(5, 1, 0));
                    Vector3    Door2Pos      = tilemap_obj.CellToWorld(positionDoor2);

                    //Cogemos coordenadas de la tercera puerta de la sala
                    Vector3Int positionDoor3 = translatePositiontoWorldCell(coordinates, new Vector3Int(8, 5, 0));
                    Vector3    Door3Pos      = tilemap_obj.CellToWorld(positionDoor3);

                    //Cogemos coordenadas de la cuarta puerta de la sala
                    Vector3Int positionDoor4 = translatePositiontoWorldCell(coordinates, new Vector3Int(1, 5, 0));
                    Vector3    Door4Pos      = tilemap_obj.CellToWorld(positionDoor4);

                    if (spawnPositions != null)
                    {
                        if (!spawnPositions.Contains(position))
                        {
                            GameObject       newSamurai    = Instantiate <GameObject>(enemy_samurai, tilePos, Quaternion.identity);
                            GameObject       SamuraiSprite = newSamurai.transform.GetChild(1).gameObject;
                            SamuraiBehaviour newBehaviour  = SamuraiSprite.GetComponent <SamuraiBehaviour>();

                            //Asignamos al Samurai los puntos guia de las puertas de su sala
                            //Puerta Norte
                            GameObject DoorPoint = Instantiate <GameObject>(GuidePoint, Door1Pos, Quaternion.identity);
                            newBehaviour.targetDoor = DoorPoint.transform;
                            newBehaviour.target     = DoorPoint.transform;
                            //Puerta Sur
                            GameObject DoorPoint2 = Instantiate <GameObject>(GuidePoint, Door2Pos, Quaternion.identity);
                            newBehaviour.targetDoor2 = DoorPoint2.transform;
                            //Puerta Este
                            GameObject DoorPoint3 = Instantiate <GameObject>(GuidePoint, Door3Pos, Quaternion.identity);
                            newBehaviour.targetDoor3 = DoorPoint3.transform;
                            //Puerta Oeste
                            GameObject DoorPoint4 = Instantiate <GameObject>(GuidePoint, Door4Pos, Quaternion.identity);
                            newBehaviour.targetDoor4 = DoorPoint4.transform;

                            spawnPositions.Add(position);
                        }
                    }
                    else
                    {
                        GameObject       newSamurai    = Instantiate <GameObject>(enemy_samurai, tilePos, Quaternion.identity);
                        GameObject       SamuraiSprite = newSamurai.transform.GetChild(1).gameObject;
                        SamuraiBehaviour newBehaviour  = SamuraiSprite.GetComponent <SamuraiBehaviour>();

                        //Asignamos al Samurai los puntos guia de las puertas de su sala
                        //Puerta Norte
                        GameObject DoorPoint = Instantiate <GameObject>(GuidePoint, Door1Pos, Quaternion.identity);
                        newBehaviour.targetDoor = DoorPoint.transform;
                        newBehaviour.target     = DoorPoint.transform;
                        //Puerta Sur
                        GameObject DoorPoint2 = Instantiate <GameObject>(GuidePoint, Door2Pos, Quaternion.identity);
                        newBehaviour.targetDoor2 = DoorPoint2.transform;
                        //Puerta Este
                        GameObject DoorPoint3 = Instantiate <GameObject>(GuidePoint, Door3Pos, Quaternion.identity);
                        newBehaviour.targetDoor3 = DoorPoint3.transform;
                        //Puerta Oeste
                        GameObject DoorPoint4 = Instantiate <GameObject>(GuidePoint, Door4Pos, Quaternion.identity);
                        newBehaviour.targetDoor4 = DoorPoint4.transform;

                        spawnPositions.Add(position);
                    }
                }
                else
                {
                }
            }
        }
    }
Beispiel #4
0
 private void Start()
 {
     //Referencia a enemigo
     samurai = GetComponentInChildren <SamuraiBehaviour>();
 }