Beispiel #1
0
 public void registerEnemy(GameEnemy enemy)
 {
     if (_enemies.ContainsKey(enemy.getName()))
     {
         Debug.Log("EnemyTable: Duplicate entry for " + enemy.getName());
     }
     else
     {
         _enemies.Add(enemy.getName(), enemy);
     }
 }
    public GameEnemyInstance(int objectId, GameEnemy template, int spawnSource)
        : base(objectId, template)
    {
        _gameInstance.AddComponent <EnemyController> ()._enemyInstance = this;
        _gameInstance.AddComponent <HealthBarController> ()._creature  = this;
        _spawnZoneSource = spawnSource;

        RuntimeAnimatorController enemyController
            = GameObject.Instantiate(getEnemyTemplate().getAnimationControllerAsset()) as RuntimeAnimatorController;

        _gameInstance.GetComponent <Animator> ().runtimeAnimatorController = enemyController;
    }
Beispiel #3
0
    protected void FindTarget()
    {
        if (target == null)
        {
            int   enemyFloorNumber   = -1;
            float frontEnemyDistance = 0;
            for (int i = 0; i < list_Enemy.Count; i++)
            {
                Transform Enemy = list_Enemy[i];

                float distance = Vector3.Distance(Enemy.position, this.transform.position);

                // 일단 사정거리 체크
                if (distance <= range)
                {
                    GameEnemy TargetEnemyTemp = Enemy.GetComponent <GameEnemy>();

                    //HP가 남아있는지
                    if (TargetEnemyTemp.getHp > 0f)
                    {
                        // 진행 경로가 더 앞서 있는 적 우선순위
                        if (enemyFloorNumber < TargetEnemyTemp.floorNumber)
                        {
                            frontEnemyDistance = Vector3.Distance(TargetEnemyTemp.targetPosition, Enemy.transform.position);
                            enemyFloorNumber   = TargetEnemyTemp.floorNumber;
                            target             = Enemy;
                            TargetEnemy        = TargetEnemyTemp;
                        }
                        // 진행 경로가 동일할 때 그 다음 타깃 경로와 거리가 짧은 적 우선순위   즉, 제일 앞선 적 우선
                        else if (enemyFloorNumber == TargetEnemyTemp.floorNumber)
                        {
                            float frontEnemyDisTemp = Vector3.Distance(TargetEnemyTemp.targetPosition, Enemy.transform.position);
                            if (frontEnemyDisTemp < frontEnemyDistance)
                            {
                                frontEnemyDistance = frontEnemyDisTemp;
                                target             = Enemy;
                                TargetEnemy        = TargetEnemyTemp;
                            }
                        }
                    }
                }
            }
        }
        else
        {
            float distance = Vector3.Distance(target.position, this.transform.position);
            if (distance > range || TargetEnemy.getHp <= 0f)
            {
                target      = null;
                TargetEnemy = null;
            }
        }
    }
    void StageStart()
    {
        List <int> keyList = dicEnemyInfo.Keys.ToList();

        for (int i = 0; i < keyList.Count; i++)
        {
            foreach (Enemy enemy in dicEnemyInfo[keyList[i]])
            {
                int trackNumber = enemy.trackNumber;

                GameObject prefab_Enemy = Resources.Load("Character Resources/" + enemy.name) as GameObject;

                GameObject newEnemy = Instantiate(prefab_Enemy, Vector3.zero, Quaternion.identity, EnemyRoot.transform);

                BoxCollider boxCollider = newEnemy.AddComponent <BoxCollider>();
                boxCollider.center    = Vector3.up * 6f;
                boxCollider.size      = new Vector3(6f, 12f, 6f);
                boxCollider.isTrigger = true;

                GameEnemy gameEnemy = newEnemy.AddComponent <GameEnemy>();
                gameEnemy.trackNumber = trackNumber;
                gameEnemy.nextGap     = enemy.nextGap;
                gameEnemy.dicTrack    = dicTrack[trackNumber];

                int no = (int)Enum.Parse(typeof(EnemyKind), enemy.name.ToUpper());

                if (dicEnemyStats.ContainsKey(no))
                {
                    gameEnemy.stats = dicEnemyStats[no];
                }
                else // 딕셔너리에 스텟 데이터가 없으면 기본값
                {
                    gameEnemy.stats = new EnemyStats(10f, 1f, 2f);
                }

                //해당 트랙의 enemy덱이 존재한다면 push
                if (dicEnemyDeck.ContainsKey(trackNumber))
                {
                    dicEnemyDeck[trackNumber].Enqueue(newEnemy);
                }
                //해당 트랙의 enemy덱이 존재하지 않다면 스택 새로 만들고 push한 후 dictionary에 추가
                else
                {
                    Queue <GameObject> newEnemyDeck = new Queue <GameObject>();
                    newEnemyDeck.Enqueue(newEnemy);

                    dicEnemyDeck.Add(trackNumber, newEnemyDeck);
                }
            }
        }

        Debug.Log("Stage Start!!");
    }
Beispiel #5
0
    public void SpawnEnemy()
    {
        GameObject nc = Instantiate(GameEnemy) as GameObject;

        GameEnemy ge = nc.GetComponent <GameEnemy>();

        ge.SetEnemy(new Enemy_Orc());
        ge.Enemy.MaxHealth *= Level;
        ge.Enemy.Health     = ge.Enemy.MaxHealth;

        nc.transform.position = new Vector3(UnityEngine.Random.Range(-25f, -15f), 20, 0);

        Enemies.Add(ge);
    }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        // Check to see who the selected enemy is
        // and load it up
        GameEnemy  selectedEnemy     = GameManager.Instance.GetSelectedEnemy();
        GameObject selectEnemyAvatar = selectedEnemy.GetAvatar();

        // we want the object name to be the actual Enemy Id
        selectEnemyAvatar.name = selectedEnemy.AvatarId;

        Debug.Log("Moving the following Enemy Into Position: " + selectedEnemy.AvatarId);

        // move avatar position to the position of the parent game object
        selectEnemyAvatar.transform.position      = gameObject.transform.position;
        selectEnemyAvatar.transform.localRotation = gameObject.transform.localRotation;
        selectEnemyAvatar.transform.localScale    = gameObject.transform.localScale;
        selectEnemyAvatar.transform.SetParent(gameObject.transform);

        // set the layer to enemy stage
        GameManager.SetLayerForAllChildren(gameObject, "VillainStage");
    }
    public GameEnemyInstance spawnSoldier(string attackerTemplate, int spawnZone, byte order)
    {
        SwarmOrder orderObj = createOrder(0, order, spawnZone);

        GameEnemy template = EnemyTable.getInstance().getEnemyByName(attackerTemplate);

        if (template == null)
        {
            return(null);
        }

        GameEnemyInstance attacker = new GameEnemyInstance(IDFactory.getNextID(), template, spawnZone);

        World.getInstance().registerEnemy(attacker);

        Vector3 spawnPosition = _positions [_computedPaths [spawnZone].getSpawnPointIndex()];

        attacker.getGameInstance().transform.position = spawnPosition;

        attacker.getGameInstance().GetComponent <EnemyController> ().setOrder(orderObj);

        return(attacker);
    }
Beispiel #8
0
    // 클릭한 유닛 디테일 창 고정 활성화
    void ClickEnemyActive()
    {
        if (ClickGameEnemy != null)
        {
            // 라이프 오버된 적 유닛
            if (ClickGameEnemy.GetIsGo == false)
            {
                ClickEnemy     = null;
                ClickGameEnemy = null;
            }
        }

        // 클릭된 유닛이 존재한다면
        if (ClickEnemy != null)
        {
            enemyPoint.transform.position = ClickEnemy.position + (Vector3.up * 4f);
            enemyDetailManager.EnemyDetailActive(true, ClickGameEnemy.stats, ClickGameEnemy.name);
        }
        else
        {
            //enemyDetailManager.EnemyDetailActive(false, new EnemyStats(), string.Empty);
            enemyPoint.SetActive(false);
        }
    }
Beispiel #9
0
        public MarioDeathStyleObject(GameEnemy ge)
            : base(ge.Location,ge.DrawSize)
        {
            Location = ge.Location;
                SizeF ObjSize = ge.GetSize();
                usedrawimage = new Bitmap((int)(ObjSize.Width * 2), (int)(ObjSize.Height * 2));
                Graphics gdraw = Graphics.FromImage(usedrawimage);
                gdraw.Clear(Color.Transparent);
                //move it temporarity...
                ge.Location = new PointF(usedrawimage.Width / 2, usedrawimage.Height / 2);

                ge.Draw(gdraw);
                //move back
                ge.Location = Location;

                //flip the image vertically.
                usedrawimage.RotateFlip(RotateFlipType.RotateNoneFlipY);
                //now, set speed to our defaults.
                InitSpeeds();

                if (ge is IMovingObject)
                {
                    Velocity = new PointF((ge as IMovingObject).Velocity.X / 2, Velocity.Y);

                }
        }
Beispiel #10
0
 public void notifyEnemyKilled(GameEnemy template)
 {
     _currentCredits += template.getKillReward();
     UIBuilder.INSTANCE.setCoinText(_currentCredits);
 }
Beispiel #11
0
    //필드의 적 RayCast
    void CursorRayHitEnemy()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo))
        {
            if (hitInfo.transform.tag.Equals("Enemy"))
            {
                // 기존 가리키고 있는 적과 다른 적 캐릭터를 가리켰다면 참조 객체 갱신
                if (CursorEnemy != hitInfo.transform)
                {
                    CursorEnemy = hitInfo.transform;
                    gameEnemy   = CursorEnemy.GetComponent <GameEnemy>();
                    enemyDetailManager.EnemyDetailActive(true, gameEnemy.stats, CursorEnemy.name);
                }
                else
                {
                    enemyDetailManager.EnemyDetailActive(true, gameEnemy.stats, CursorEnemy.name);
                }

                // 적 유닛을 가리키는 화살표 활성화
                enemyPoint.SetActive(true);
                enemyPoint.transform.position = CursorEnemy.transform.position + (Vector3.up * 4f);


                // 적 유닛 클릭
                if (Input.GetMouseButtonDown(0))
                {
                    ClickEnemy     = CursorEnemy;
                    ClickGameEnemy = ClickEnemy.GetComponent <GameEnemy>();
                    enemyDetailManager.EnemyDetailActive(true, ClickGameEnemy.stats, ClickEnemy.name);
                }
            }
            else // 적을 가리키고 있지 않다면 비활성화
            {
                if (ClickEnemy == null || Input.GetMouseButtonDown(0))
                {
                    ClickEnemy     = null;
                    ClickGameEnemy = null;
                    enemyDetailManager.EnemyDetailActive(false, new EnemyStats(), string.Empty);
                    enemyPoint.SetActive(false);
                }

                if (ClickEnemy != null)
                {
                    enemyPoint.SetActive(true);
                    enemyDetailManager.EnemyDetailActive(true, ClickGameEnemy.stats, ClickEnemy.name);
                }
            }
        }
        else
        {
            // 클릭된 유닛이 없을 경우 초기화
            if (ClickEnemy == null)
            {
                //enemyDetailManager.EnemyDetailActive(false, new EnemyStats(), string.Empty);
                enemyPoint.SetActive(false);
            }
            return;
        }
    }
Beispiel #12
0
    public void RemoveEnemy(GameEnemy e)
    {
        Enemies.Remove(e);

        EnemiesKilledThisLevel++;
    }