Inheritance: MonoBehaviour
示例#1
0
    private void SpawnEnemy(EnemySpawnPoint sp)
    {
        var enemy      = (GameObject)Instantiate(enemyPrefab, sp.transform.position, Quaternion.identity);
        var controller = enemy.GetComponentInChildren <EnemyShipControllerV2>();

        controller.waypoints = waypoints;
    }
示例#2
0
 public void AddPendingSpawnPoint(EnemySpawnPoint newSpawnPoint)
 {
     if (!currentlyPendingSpawnPoints.Contains(newSpawnPoint))
     {
         currentlyPendingSpawnPoints.Add(newSpawnPoint);
     }
 }
示例#3
0
 public static void RemoveSpawnPoint(EnemySpawnPoint spawnPoint)
 {
     if (instance.spawnPoints.Contains(spawnPoint) == true)
     {
         instance.spawnPoints.Remove(spawnPoint);
     }
 }
示例#4
0
 /// Use as a constructor to init local variables
 protected virtual void EnterState(Enemy owner, GameObject lastInfluence)
 {
     this.owner    = owner;
     lastThreat    = lastInfluence;
     spawn         = owner.Spawn;
     abilComponent = owner.abilityComponent;
 }
示例#5
0
 public static void AddSpawnPoint(EnemySpawnPoint spawnPoint)
 {
     if (instance.spawnPoints.Contains(spawnPoint) == false)
     {
         instance.spawnPoints.Add(spawnPoint);
     }
 }
示例#6
0
    public BattlefieldData LoadBattlefieldData(string fileName, bool isFullPath = false)
    {
        string fullFile = BATTLEFIELD_SAVE_DIRECTORY + fileName + ".dat";

        if (isFullPath)
        {
            fullFile = fileName;
        }

        BattlefieldData data = Utility.LoadObjectFromFile <BattlefieldData> (fullFile);

        if (data != null)
        {
            data.spawns = new List <EnemySpawnPoint> ();
            for (int i = 0; i < data.spawnsX.Length; i++)
            {
                Vector3 start = new Vector3(data.spawnsX[i], data.spawnsY[i]);
                Vector3 end   = new Vector3(data.endsX[i], data.endsY[i]);

                EnemySpawnPoint spawn    = ScriptableObject.CreateInstance <EnemySpawnPoint>();
                EnemyEndPoint   endPoint = ScriptableObject.CreateInstance <EnemyEndPoint>();

                spawn.worldPosition    = start;
                endPoint.worldPosition = end;

                spawn.endPoint = endPoint;
                data.spawns.Add(spawn);
            }
            return(data);
        }
        return(null);
    }
示例#7
0
    private void SpawnEnemy(Enemy enemy)
    {
        Debug.Log("Spawning Enemy");
        EnemySpawnPoint spawn = spawnPoints[Random.Range(0, spawnPoints.Length)];

        Instantiate(enemy, spawn.transform.position, spawn.transform.rotation);
    }
示例#8
0
    public GameObject SpawnEnemy(EnemySpawnPoint point, EnemyType type)
    {
        GameObject originalEnemy;

        switch (type)
        {
        case EnemyType.ET_TRASH:
            originalEnemy = trashEnemy;
            break;

        case EnemyType.ET_MELEE:
            originalEnemy = meleeEnemy;
            break;

        case EnemyType.ET_RANGED:
            originalEnemy = rangedEnemy;
            break;

        default:
            originalEnemy = trashEnemy;
            break;
        }

        GameObject spawnedEnemy = Instantiate(originalEnemy, point.transform.position, point.transform.rotation);

        return(spawnedEnemy);
    }
示例#9
0
    private void SpawnEnemy()
    {
        EnemySpawnPoint spawnPoint = GetSpawnPoint();
        Rat             newRat     = Instantiate(enemyPrefab, spawnPoint.transform.position, Quaternion.identity);

        newRat.transform.parent = transform;
    }
示例#10
0
    void SetAvailableSpawnpoints()
    {
        Pathfinding.BakePaths();
        availableSpawns = new List <EnemySpawnPoint>();

        for (int i = 0; i < Game.game.enemySpawnPoints.Count; i++)
        {
            EnemySpawnPoint sp = Game.game.enemySpawnPoints[i];
            Vector2         wp = Pathfinding.finder.WorldToNode(sp.worldPosition) + new Vector2(0.5f, 0.5f);
            int             x  = Mathf.RoundToInt(wp.x) - 1;
            int             y  = Mathf.RoundToInt(wp.y) - 1;

            if (Game.isWalled[x, y] == Game.WallType.None && sp.path != null)
            {
                availableSpawns.Add(sp);
                sp.blocked = false;
            }
            else
            {
                sp.blocked = true;
            }
        }

        // So many steps just to convert a single coordinate to rounded numbers..
    }
示例#11
0
    public void SetSpawnIndicators()
    {
        foreach (GameObject i in currentIndicators)
        {
            Destroy(i);
        }

        currentIndicators.Clear();
        SetAvailableSpawnpoints();
        Pathfinding.BakePaths();

        for (int i = 0; i < Game.game.enemySpawnPoints.Count; i++)
        {
            EnemySpawnPoint point = Game.game.enemySpawnPoints[i];

            Vector3    next         = Game.game.GetVoidDirection(point.worldPosition);
            Quaternion rotation     = Quaternion.Euler(0f, 0f, Angle.CalculateAngle(point.worldPosition, next) + 180f);
            GameObject newIndicator = (GameObject)Instantiate(enemySpawnIndicator, point.worldPosition, rotation);

            currentIndicators.Add(newIndicator);
            SpriteRenderer sprite = newIndicator.GetComponentInChildren <SpriteRenderer> ();

            if (point.blocked)
            {
                sprite.color = Color.red;
            }
            else
            {
                sprite.color = Color.green;
            }
        }
    }
示例#12
0
    public Vector3 RandomSpawnPoint()
    {
        int randomPos = Random.Range(0, spawnPoints.Length);

        EnemySpawnPoint eSpawnPoint = spawnPoints[randomPos];

        return(eSpawnPoint.transform.position);
    }
示例#13
0
 public static void checkBossWave(int spawnCount)
 {
     if (spawnCount != 0 && spawnCount % BOSS_WAVE_LIMIT == 0)
     {
         EnemySpawnPoint.setSpawn();
         spawnBoss();
     }
 }
示例#14
0
    void destroyBoss()
    {
        BossSpawnPoint.continueWave();
        Background.increaseSpeed();
        Enemy.buffEnemy();
        EnemySpawnPoint.buffSpawnPoint();

        Destroy(gameObject);
    }
示例#15
0
    void Awake()
    {
        health = maxHealth;
        submarineResources = FindObjectOfType<Submarine_Resources>();

        if (GetComponent<EnemyRespawn>()) {
            respawnPoint = GetComponent<EnemyRespawn>().point;
        }
    }
    public EnemySpawnPoint Convert()
    {
        EnemySpawnPoint point = ScriptableObject.CreateInstance <EnemySpawnPoint> ();

        point.worldPosition          = transform.position;
        point.endPoint               = ScriptableObject.CreateInstance <EnemyEndPoint> ();
        point.endPoint.worldPosition = endPoint;
        return(point);
    }
示例#17
0
 void Update()
 {
     if (Time.timeScale != 0 &&
         !isBossEntered && !GameObject.FindObjectOfType <Boss>())
     {
         int spawnCount = EnemySpawnPoint.getBaseSpawnCount();
         checkBossWave(spawnCount);
     }
 }
示例#18
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        EnemySpawnPoint ep = (EnemySpawnPoint)target;

        if (GUILayout.Button("Show path"))
        {
            ep.drawPath = !ep.drawPath;
        }
    }
示例#19
0
    public GameObject SpawnEnemy(EnemySpawnPoint point, EnemyType type, EnemyObserver enemyObserver)
    {
        GameObject        go = SpawnEnemy(point, type);
        CapsuleController capsuleController = go.GetComponent <CapsuleController>();

        if (capsuleController != null && enemyObserver != null)
        {
            capsuleController.Observer = enemyObserver;
        }

        return(go);
    }
示例#20
0
    /// <summary>
    /// Randomly spawns given number of enemies on given spawn points.
    /// </summary>
    /// <param name="spawnPoints">Spawn points to use.</param>
    /// <param name="enemiesToSpawn">Number of enemies to spawn.</param>
    private void UseSpawnPoints(EnemySpawnPoint[] spawnPoints, int enemiesToSpawn)
    {
        int spCount = spawnPoints.Length;

        for (int i = 0; i < enemiesToSpawn; i++)
        {
            EnemySpawnPoint spawnPoint    = spawnPoints[random.Next(spCount)];
            GameObject      objectToSpawn = spawnPoint.SpawnEnemy();
            Debug.Log("Spawning: " + objectToSpawn.name + " at " + spawnPoint.gameObject.name);
            GameObject newObject = Instantiate(objectToSpawn, spawnPoint.transform.position, spawnPoint.transform.rotation);
        }
    }
示例#21
0
    void GenerateDefaultSpawnpoints()
    {
        for (int x = 1; x < battlefieldWidth + 1; x++)
        {
            EnemySpawnPoint spawn = ScriptableObject.CreateInstance <EnemySpawnPoint>();
            EnemyEndPoint   end   = ScriptableObject.CreateInstance <EnemyEndPoint>();

            spawn.worldPosition = new Vector3(x - battlefieldWidth / 2f - 0.5f, battlefieldHeight / 2f - 0.5f);
            end.worldPosition   = new Vector3(x - battlefieldWidth / 2f - 0.5f, -battlefieldHeight / 2f - 0.5f);

            spawn.endPoint = end;
            enemySpawnPoints.Add(spawn);
        }
    }
示例#22
0
文件: Grotto.cs 项目: Grivik/Zelda_VR
    void InstantiateNPCSpawnPoint()
    {
        if (_npcSpawnPoint != null)
        {
            return;
        }

        GameObject g = Instantiate(NpcSpawnPointPrefab);

        g.transform.SetParent(npcContainer);
        g.transform.localPosition = Vector3.zero;

        _npcSpawnPoint = g.GetComponent <EnemySpawnPoint>();
    }
示例#23
0
 void AssignEnemySpawnPointsToRooms()
 {
     foreach (Transform child in transform)
     {
         EnemySpawnPoint sp = child.GetComponent <EnemySpawnPoint>();
         if (sp != null)
         {
             DungeonRoom dr = DungeonRoom.GetRoomForPosition(sp.transform.position);
             if (dr == null)
             {
                 //print(" sp -> " + sp.name + ": " + sp.transform.position.x + ", " + sp.transform.position.z);
                 continue;
             }
             dr.AddEnemySpawnPoint(sp);
         }
     }
 }
示例#24
0
    public static void continueWave()
    {
        Score.increaseScore();
        Feet.instance.startAnimation();
        Background.setBackgroundActive();
        UIHandler.changeMusicClip();

        EnemySpawnPoint.setSpawn();
        EnemySpawnPoint.increaseBaseSpawnCount();

        if (EnemySpawnPoint.getBaseSpawnCount() >= GHOST_LIMIT)
        {
            Enemy.setGhostColor();
        }

        isBossEntered = false;
    }
    Texture2D GenerateTexture(Game.BattlefieldData data)
    {
        int width  = data.walls.GetLength(0);
        int height = data.walls.GetLength(1);

        Texture2D tex = new Texture2D(width, height);

        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                switch ((Game.WallType)data.walls[x, y])
                {
                case Game.WallType.Level:
                    tex.SetPixel(x, y, Color.red);
                    break;

                case Game.WallType.None:
                    tex.SetPixel(x, y, new Color(0f, 0.04f, 0f));
                    break;
                }
            }
        }

        for (int i = 0; i < data.spawns.Count; i++)
        {
            EnemySpawnPoint sp  = data.spawns[i];
            Vector3         wsp = sp.worldPosition + new Vector3(data.width, data.height) / 2f;
            int             sx  = Mathf.RoundToInt(wsp.x);
            int             sy  = Mathf.RoundToInt(wsp.y) - 1;

            Vector3 wep = sp.endPoint.worldPosition + new Vector3(data.width, data.height) / 2f;
            int     ex  = Mathf.RoundToInt(wep.x);
            int     ey  = Mathf.RoundToInt(wep.y);

            tex.SetPixel(sx, sy, Color.red);
            tex.SetPixel(ex, ey, Color.green);
        }

        tex.filterMode = FilterMode.Point;
        tex.Apply();

        return(tex);
    }
示例#26
0
    private void resetGame()
    {
        Score.resetScore();
        Skill.instance.resetStack();
        EnemySpawnPoint.resetSpawnPoint();
        Enemy.resetEnemy();
        BossSpawnPoint.resetSpawnPoint();
        Boss.resetBoss();
        Background.resetBackground();

        Character character = GameObject.FindGameObjectWithTag("Player").GetComponent <Character>();

        character.resetCharacter();
        Feet.instance.startAnimation();

        DestroyClass.destroyObjectsByTag("Enemy");
        DestroyClass.destroyObjectsByTag("Projectile");

        aud.clip = (AudioClip)Resources.Load("Audios/Musics/GameMusic");
    }
示例#27
0
    //pick a spawner to target for enemy checks.
    private void setLaneSpawner()
    {
        EnemySpawnPoint[] spawners = GameObject.FindObjectsOfType <EnemySpawnPoint>();

        foreach (EnemySpawnPoint point in spawners)
        {
            if (point.transform.position.y == this.transform.position.y)
            {
                spawnPoint = point;
                break;
            }
        }

        if (spawnPoint == null)
        {
            Debug.LogError("Spawn point cannot be found, this is outside of a lane.");
        }
        else
        {
            Debug.Log("Spawner discovered: " + spawnPoint.name);
        }
    }
示例#28
0
 void OnDrawGizmos()
 {
     if (waveStarted)
     {
         for (int i = 0; i < availableSpawns.Count; i++)
         {
             EnemySpawnPoint point = availableSpawns[i];
             for (int j = 0; j < point.path.Length - 1; j++)
             {
                 UnityEngine.Debug.DrawLine(point.path[j], point.path[j + 1], Color.red);
             }
         }
     }
     if (Game.game && Game.game.enemySpawnPoints != null)
     {
         for (int i = 0; i < Game.game.enemySpawnPoints.Count; i++)
         {
             Gizmos.DrawSphere(Game.game.enemySpawnPoints[i].worldPosition, 0.5f);
             Gizmos.DrawSphere(Game.game.enemySpawnPoints[i].endPoint.worldPosition, 0.25f);
             Gizmos.DrawLine(Game.game.enemySpawnPoints[i].worldPosition, Game.game.enemySpawnPoints[i].endPoint.worldPosition);
         }
     }
 }
 void Awake()
 {
     anim  = GetComponent <Animator> ();
     point = GetComponent <EnemySpawnPoint>();
 }
 private void SpawnEnemy(EnemySpawnPoint sp)
 {
     var enemy = (GameObject)Instantiate(enemyPrefab, sp.transform.position, Quaternion.identity);
     var controller = enemy.GetComponentInChildren<EnemyShipControllerV2>();
     controller.waypoints = waypoints;
 }
示例#31
0
 private bool CanSpawnAtPoint(EnemySpawnPoint sp)
 {
     return(true);
 }
 private bool CanSpawnAtPoint(EnemySpawnPoint sp)
 {
     return true;
 }
示例#33
0
 public void RegisterEnemySpawnPoint(EnemySpawnPoint enemySpawnPoint)
 {
     _enemySpawnPoints.Add(enemySpawnPoint);
 }