示例#1
0
 public void DeadAnd(CAnt deadAnt)
 {
     if (antList.Contains(deadAnt))
     {
         antList.Remove(deadAnt);
     }
     Destroy(deadAnt.gameObject);
 }
示例#2
0
        public void TourTest()
        {
            CAnt Tourtestant = new CAnt(TEST_POINT_1);

            Assert.AreSame(TEST_POINT_1, Tourtestant.GetTour().getPoint(0));
            Tourtestant.CurrentPoint = TEST_POINT_2;
            Assert.AreSame(TEST_POINT_2, Tourtestant.GetTour().getPoint(1));
            Tourtestant.CurrentPoint = TEST_POINT_3;
            Assert.AreSame(TEST_POINT_3, Tourtestant.GetTour().getPoint(2));
        }
示例#3
0
    // Start is called before the first frame update
    private void Start()
    {
        //GameObject go = Instantiate(ant, transform);
        //go.GetComponent<CAnt>().SetAnt(new Vector2Int(5, 3));
        GameObject go  = Instantiate(mineAnt, transform);
        CAnt       ant = go.GetComponent <CAnt>();

        antList.Add(ant);
        ant.SetAnt(new Vector2Int(17, 5), AntDir.Left);
    }
示例#4
0
        public void construtorTest()
        {
            CAnt testAnt = new CAnt(TEST_POINT_1);

            Assert.AreSame(testAnt.CurrentPoint, TEST_POINT_1);

            foreach (CTSPPoint point in testAnt.PointsToVisit)
            {
                Assert.AreSame(CTSPPointList.getInstance().getPoint(point.getLabel()), point);
            }
        }
示例#5
0
 void Update()
 {
     if (animator.GetCurrentAnimatorStateInfo(0).IsName("Mole_Out"))
     {
         for (int i = 0; i < arr.Length; i++)
         {
             if (CAntManager.Instance.AntLocationCheck(arr[i]) && TileManager.instance.shiledArray[arr[i].x, arr[i].y] <= 0)
             {
                 SoundManager.instance.se05away.Play();
                 CAnt ant = CAntManager.Instance.GetAnt(arr[i]);
                 CAntManager.Instance.DeadAnd(ant);
             }
         }
     }
 }
示例#6
0
    private void Update()
    {
        if (createNum < createAnts.Length)
        {
            time += Time.deltaTime;
            if (time >= createTime)
            {
                time -= createTime;
                GameObject go  = Instantiate((createAnts[createNum].antType == AntType.NormalAnt) ? normalAnt : mineAnt, transform);
                CAnt       ant = go.GetComponent <CAnt>();
                ant.SetAnt(createAnts[createNum].createAntPos);
                if (createAnts[createNum].antType == AntType.NormalAnt)
                {
                    normalAntCount++;
                    ant.Order(5000 + (normalAntCount * 100));
                }
                else
                {
                    mineAntCount++;
                    ant.Order(10000 + (mineAntCount * 100));
                }

                antList.Add(ant);
                createNum++;
                if (createNum < createAnts.Length)
                {
                    createTime = createAnts[createNum].antCreateTime;
                }
            }
        }
        else
        {
            GameManager.instance.AntNumFlag = true;
        }
        danceTime += Time.deltaTime;
        if (danceTime >= nextDanceTime)
        {
            danceTime = 0f;
            Dance();
        }
    }
示例#7
0
    public void UpdateObjectTile(bool flag, Vector2Int v)
    {
        Tile tile;

        if (0 > v.x || v.x >= mapW || 0 > v.y || v.y >= mapH)
        {
            tile = Tile.데드존;
        }

        if (flag)
        {
            tile = GetTile(tileItem, v);
            if (tile == Tile.마늘 || tile == Tile.응가 || tile == Tile.꿀)
            {
                colArray[v.x, v.y] -= Time.deltaTime;
                if (colArray[v.x, v.y] <= 0)
                {
                    SetTile(tileItem, v, Tile.공백);
                    SetTile(v, Tile.흙);
                }
            }
            else if (tile == Tile.나뭇잎)
            {
                if (colArray[v.x, v.y] <= 0)
                {
                    SetTile(tileItem, v, Tile.공백);
                    SetTile(v, Tile.흙);
                }
            }
            else if (tile == Tile.방울)
            {
                shiledArray[v.x, v.y] -= Time.deltaTime;
                if (shiledArray[v.x, v.y] <= 0)
                {
                    SetTile(tileItem, v, Tile.공백);
                    SetTile(v, Tile.흙);
                }
            }
            else if (tile == Tile.데드존)
            {
                if (CAntManager.Instance.AntLocationCheck(v))
                {
                    SoundManager.instance.se05away.Play();
                    CAnt ant = CAntManager.Instance.GetAnt(v);
                    CAntManager.Instance.DeadAnd(ant);
                }
            }
            else if (tile == Tile.끝)
            {
                if (CAntManager.Instance.AntLocationCheck(v))
                {
                    SoundManager.instance.se05away.Play();
                    CAnt ant = CAntManager.Instance.GetAnt(v);
                    try
                    {
                        CMineAnt emp0 = (CMineAnt)ant;
                        if (emp0)
                        {
                            GameManager.instance.nowMineNormalAnt += 1;
                            //Debug.Log("채굴개미 : " + GameManager.instance.nowMineNormalAnt);
                        }
                    }
                    catch { }

                    try
                    {
                        CNormalAnt emp1 = (CNormalAnt)ant;
                        if (emp1)
                        {
                            GameManager.instance.nowNormalAnt += 1;
                            //Debug.Log("일반개미 : " + GameManager.instance.nowNormalAnt);
                        }
                    }
                    catch { }
                    CAntManager.Instance.DeadAnd(ant);
                }
            }
        }
        else
        {
            tile = GetTile(tileMap, v);
            if (tile == Tile.데드존)
            {
                if (CAntManager.Instance.AntLocationCheck(v))
                {
                    SoundManager.instance.se05away.Play();
                    CAnt ant = CAntManager.Instance.GetAnt(v);
                    CAntManager.Instance.DeadAnd(ant);
                }
            }
        }
    }
示例#8
0
    void GameEndCheck()
    {
        if (EndGame)
        {
            return;
        }

        if (nowNormalAnt >= normalAntTargetAmount && nowMineNormalAnt >= mineAntTargetAmount)
        {
            GameResult = 1;
            SoundManager.instance.se03succes.Play();
            UIManager.instance.winUI.SetActive(true);
            EndGame = true;
            return;
        }

        if (timeLimit <= 0)
        {
            GameResult = 2;
            SoundManager.instance.se04fail.Play();
            UIManager.instance.loseUI.SetActive(true);
            EndGame = true;
            return;
        }

        if (AntNumFlag)
        {
            int minenum   = 0;
            int normalnum = 0;

            for (int i = 0; i < CAntManager.Instance.antList.Count; i++)
            {
                CAnt ant = CAntManager.Instance.antList[i];
                try
                {
                    CMineAnt emp0 = (CMineAnt)ant;
                    if (emp0)
                    {
                        minenum++;
                    }
                }
                catch { }

                try
                {
                    CNormalAnt emp1 = (CNormalAnt)ant;
                    if (emp1)
                    {
                        normalnum++;
                    }
                }
                catch { }
            }

            if (minenum < (mineAntTargetAmount - nowMineNormalAnt) || normalnum < (normalAntTargetAmount - nowNormalAnt))
            {
                GameResult = 2;
                SoundManager.instance.se04fail.Play();
                UIManager.instance.loseUI.SetActive(true);
                EndGame = true;
                return;
            }
        }
    }