Exemplo n.º 1
0
    IEnumerator spawnTimer(float time)
    {
        yield return(new WaitForSeconds(time));

        EnemyPrefab enemy = enemies[Random.Range(0, enemies.Length - 1)];

        Instantiate(enemy.prefab,
                    RandomVec.getRandomPosition(enemy.positionConstraints, _player.transform.position, enemy.minPlayerDistance),
                    Quaternion.Euler(RandomVec.getRandomVector(enemy.rotationConstraints)));
    }
Exemplo n.º 2
0
    public Enemy Spawn(Transform spawnPoint)
    {
        EnemyPrefab randomPrefab = enemiesToSpawn[Random.Range(0, enemiesToSpawn.Count)];
        GameObject  clone        = Instantiate(randomPrefab.prefabs[Random.Range(0, randomPrefab.prefabs.Length)], spawnPoint.position, Quaternion.identity) as GameObject;

        Enemy enemy = clone.GetComponent <Enemy>();

        enemy.GetComponent <EnemyAttributes>().Init(randomPrefab.minLevel, randomPrefab.maxLevel);
        enemy.LeftEdge  = spawnPoint.GetChild(0);
        enemy.RightEdge = spawnPoint.GetChild(1);

        return(enemy);
    }
Exemplo n.º 3
0
 private void PostBattleReward(EnemyPrefab b)
 {
     // Player loses obedince towards losing enemy
     player.RelationshipTracker.GetTempRelationshipWith(b).ObedienceStat.BaseValue--;
     // Losing enemy gain obedince and loses affection towards player
     b.RelationshipTracker.GetTempRelationshipWith(player).ObedienceStat.BaseValue++;
     b.RelationshipTracker.GetTempRelationshipWith(player).AffectionStat.BaseValue--;
     Player.ExpSystem.GainExp(Player.ExpSystem.Exp + b.Reward.ExpReward);
     b.Reward.HandleDrops(Player);
     Player.Currency.Gold += Player.Perks.HasPerk(PerksTypes.Greedy)
         ? b.Reward.GoldReward * PerkEffects.Greedy.ExtraGold(Player.Perks)
         : b.Reward.GoldReward;
     b.IsQuest.CheckQuest();
 }
Exemplo n.º 4
0
 private void SpawnEnemies()
 {
     if (currEnemies.Count > 0)
     {
         for (int i = 0; i < enemyToAdd; i++)
         {
             EnemyPrefab prefab = currEnemies[rnd.Next(currEnemies.Count)];
             if (prefab != null)
             {
                 EnemyPrefab newEnemy = Instantiate(prefab, GetPosistion(), Quaternion.identity, transform);
                 newEnemy.name = prefab.name;
                 addedEnemies.Add(newEnemy);
             }
             else
             {
                 Debug.LogWarning(MapEvents.CurrentMap + " is missing enemies references");
             }
         }
     }
 }
Exemplo n.º 5
0
    public void SpawnEnemy(EnemyPrefab enemyPrefab, int level = 0)
    {
        if (enemyPrefab == null)
        {
            return;
        }
        GameObject go = Instantiate(enemyPrefab.BasePrefab, GetRandomSpawnPoint(), Quaternion.identity, transform);

        go.name = enemyPrefab.name + " lvl: " + level;
        Enemy enemy = go.AddComponent <Enemy>();

        enemy.enemyPrefab = enemyPrefab;
        enemy.Level       = level;
        enemy.PopulateFromPrefab();
        enemy.EnemiesList = EnemiesList;
        enemy.TurretsList = TurretsList;
        enemy.WallsList   = WallsList;
        enemy.House       = House;
        EnemiesList.Register(enemy);
    }
Exemplo n.º 6
0
 /// <summary> Creates a new instance of the given prefab. </summary>
 /// <param name="enemyPrefab"> The prefab to create an instance of. </param>
 /// <param name="position"> The location at which the new instance should be placed. </param>
 /// <param name="euler"> The rotation at which the new instance should be placed. </param>
 /// <returns> A GameObject representing the newly created instance. </returns>
 public GameObject Create(EnemyPrefab enemyPrefab, Vector3 position, Quaternion euler)
 {
     return(Create(enemyPrefab.Template, position, euler));
 }
Exemplo n.º 7
0
 public bool CanCreate(EnemyPrefab prefab)
 {
     return(true);
 }
Exemplo n.º 8
0
 public WaveSegment(EnemyPrefab enemyToSpawn, int numberOfEnemies = 1, int enemyLevel = 0)
 {
     this.enemyToSpawn = enemyToSpawn;
     NumberOfEnemies   = numberOfEnemies;
     EnemyLevel        = enemyLevel;
 }
Exemplo n.º 9
0
    GameObject clickedGameObject;//クリックしたオブジェクト
    void Update()
    {
        faithPointText.text = "信仰P:" + faithPoint.ToString();

        /*  if(ThunderboltFlag == true && faithPoint>= ThunderboltPoint) { if (Input.GetMouseButtonDown(0))
         *    {
         *        clickedGameObject = null;
         *
         *        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         *        RaycastHit hit = new RaycastHit();
         *
         *        if (Physics.Raycast(ray, out hit))
         *        {
         *            if (hit.transform.tag == "Enemy" || hit.transform.tag == "Building" || hit.transform.tag == "Village")
         *            {
         *                clickedGameObject = hit.collider.gameObject;
         *                Instantiate(thunderboltParticle, clickedGameObject.transform.position, Quaternion.identity);
         *                Destroy(clickedGameObject);
         *                ThunderboltFlag = false;
         *                faithPoint -= ThunderboltPoint;
         *            }
         *        }
         *    } }*/
        if (type == MODE_TYPE.Neutral)
        {
            modeText.text = "通常モード"; SummonDemonParent.SetActive(false); ConstructionParent.SetActive(false);
        }
        else if (type == MODE_TYPE.SummonDemon)
        {
            modeText.text = "魔物召喚モード"; SummonDemonParent.SetActive(true);
        }
        else if (type == MODE_TYPE.Destruction)
        {
            modeText.text = "破壊モード"; if (Input.GetMouseButtonDown(0))
            {
                if (ClickIvent().tag == "Obstacle")
                {
                    if (faithPoint >= DestructionPoint)
                    {
                        DecreaseFaith(DestructionPoint); Instantiate(thunderboltParticle, clickedGameObject.transform.position, Quaternion.identity); Destroy(clickedGameObject);
                    }
                }
            }
        }                                                                                                                                                                               //破壊モードの時、建物をクリックしたら破壊。
        else if (type == MODE_TYPE.Construction)
        {
            modeText.text = "建設モード"; ConstructionParent.SetActive(true);
        }
        else if (type == MODE_TYPE.Battle)
        {
            modeText.text = "戦闘モード";
            if (targetEnemyPrefab)
            {
                TextsHP.text = "HP:" + targetEnemyPrefab.HP + "/" + targetEnemyPrefab.MaxHP;
            }
            if (Input.GetMouseButtonDown(0))
            {
                GameObject target = ClickIvent();
                if (!(target == null))
                {
                    if (target.tag == "Enemy")
                    {
                        targetEnemyPrefab = target.GetComponent <EnemyPrefab>(); ClickEnemy();
                    }
                }
            }
        }//バトルモード時、敵をクリックするとスキルウィンドウ表示



        if (Input.GetKeyDown(KeyCode.X))
        {
            GetFaith(100);
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     Parent        = transform.parent.GetComponent <EnemyPrefab>();
     startPosition = Parent.transform.position;
 }