コード例 #1
0
ファイル: NPCCommander.cs プロジェクト: MaiDaine/Prototype
        protected virtual void SpawnUnit(CardData unitData, Vector3 position)
        {
            NonControllableUnit unit = Instantiate <NonControllableUnit>(
                (NonControllableUnit)unitData.unit,
                spawnPosition,
                board.Value.npcSpawnPosition.rotation
                );

            unit.Initialize(playerHero, unitData.unitStats, "EnemyTeam");
            npcUnits.Add(unit);
        }
コード例 #2
0
 private void Update()
 {
     if (timerEvent > 0f)
     {
         timerEvent -= Time.deltaTime;
         if (timerEvent <= 0f)
         {
             lastWave = encounterEvent.NextPhase(ref nextSpawn);
             if (!lastWave)
             {
                 timerSpawn = Time.deltaTime;
             }
             else
             {
                 NonControllableUnit tmp = Instantiate((NonControllableUnit)boss.unit, bossSpawnPoint);
                 tmp.Initialize(activeHero, boss.unitStats, "EnemyTeam");
                 enemyUnits.Add(tmp);//TODO EVENT CLEAR
             }
         }
     }
     if (timerSpawn > 0f)
     {
         timerSpawn -= Time.deltaTime;
         if (timerSpawn <= 0f)
         {
             timerSpawn = SpawnUnit(nextSpawn[0]);
             nextSpawn.RemoveAt(0);
             timerEvent -= timerSpawn;
             if (nextSpawn.Count == 0)
             {
                 timerEvent *= -1f;
                 timerSpawn  = -1f;
             }
         }
     }
 }
コード例 #3
0
        private void OnTriggerEnter(Collider other)
        {
            Unit unit = other.gameObject.GetComponent <Unit>();

            if (unit != null && unit.GetComponent <UnitHealth>().alive)
            {
                if (playerSide.items.Contains(unit))
                {
                    playerSide.Remove(unit);
                    NPCSide.Add(unit);
                }
                else
                {
                    NPCSide.Remove(unit);
                    playerSide.Add(unit);
                }
            }
        }
コード例 #4
0
        private void Update()
        {
            if (isSpawning)
            {
                Vector3 boardPosition;
                bool    validRayCastHit;

                validRayCastHit         = rayCast.BoardRayCast(out boardPosition, spawnLayer.Value);
                unit.transform.position = new Vector3(boardPosition.x, unitSizeOffset, boardPosition.z);

                if (validRayCastHit && Input.GetMouseButtonDown(0))
                {
                    ((NonControllableUnit)unit).Initialize(npcHero, selectedCard.unitStats, "PlayerTeam");
                    playerSide.Add(unit);
                    unit       = null;
                    isSpawning = false;
                }
            }
            commander.Think();
        }
コード例 #5
0
        private void Awake()
        {
            rayCast            = this.GetComponent <Prototype.RayCast>();
            joystickController = new JoystickController();
            keyboardController = new KeyboardController(rayCast);
            spellCasting       = new SpellCasting(this);

            playerUnits.items.Clear();
            for (int i = 0; i < units.Length && units[i] != null; i++)
            {
                unitPortraits[i].gameObject.SetActive(true);
                units[i] = Instantiate(units[i]);
                units[i].gameObject.SetActive(false);
                units[i].Initialize(this, unitPortraits[i]);
            }
            currentUnit     = units[0];
            currentAnimator = currentUnit.GetComponentInChildren <Animator>();
            currentUnit.transform.position = playerSpawn;
            currentUnit.gameObject.SetActive(true);
            playerUnits.Add(currentUnit);
            GetComponent <CameraController>().UpdateTarget(currentUnit.gameObject);
            spellCasting.UpdateSpellBook(ref currentUnit.spellBook);
        }