Пример #1
0
    public override void updateObjectMapInformation()
    {
        floorData oldFloorData = gameModel.instance.getFloorDatas(InMapV3Pos);

        oldFloorData.UnregisterAntData(this, isFriendly);
        if (FollowMinePathSmellRecord)
        {
            oldFloorData.UnregisterFollowMinePathAntData(this);
            FollowMinePathSmellRecord = false;
        }
        if (randWalkSmellRecord)
        {
            oldFloorData.UnregisterRandWalkAntData(this);
            randWalkSmellRecord = false;
        }

        InMapV3Pos = gameModel.instance.charWorldToMapV3(transform);

        floorData newFloorData = gameModel.instance.getFloorDatas(InMapV3Pos);

        newFloorData.RegisterAntData(this, isFriendly);
        if (antMiningActivity == AntMiningActivityState.none)
        {
            newFloorData.RegisterRandWalkAntData(this);
            randWalkSmellRecord = true;
        }

        if (antMiningActivity == AntMiningActivityState.followTheMinePath)
        {
            newFloorData.RegisterFollowMinePathAntData(this);
            FollowMinePathSmellRecord = true;
        }
    }
Пример #2
0
    public Ant checkAnt_EnemyInThisWall(Vector2Int mapV3)
    {
        floorData  floorData = getFloorDatas(mapV3);
        List <Ant> ants      = floorData.enemyAnts;

        return(pickUpAntFromArray(ants));
    }
Пример #3
0
    void Start()
    {
        //从缓存中读取数据
        ff         = GameObject.Find("Main Camera").GetComponent <gameData>().floorDataList[player.playerInfloor - 1];
        enemylist  = ff.enemylist;
        doorlist   = ff.doorlist;
        wupinglist = ff.wupinglist;
        init       = ff.init;
        initUp     = ff.initUp;

        showEnemy();
        showDoor();
        showWuping();
        if (!player.isLoad)//非加载存档
        {
            if (player.upOrdown == "up")
            {
                showHero(transMap(init));
            }
            else if (player.upOrdown == "down")
            {
                showHero(transMap(initUp));
            }
        }
        else
        {//加载存档
            showHero(transMap(player.playerPos));
        }
    }
Пример #4
0
    void leaveSomeSmell()
    {
        floorData curFloorData = gameModel.instance.getFloorDatas(InMapV3Pos);

        if (!isFriendly)
        {
            curFloorData.floorSmell.enemySmell = 50;
        }
        else
        {
            curFloorData.floorSmell.friendlySmell = 50;
        }
    }
Пример #5
0
    public void init()
    {
        floorDatas = new floorData[maxFloorLength, maxFloorLength];
        for (int y = 0; y < maxFloorLength; y++)
        {
            for (int x = 0; x < maxFloorLength; x++)
            {
                floorDatas[x, y] = new floorData();
            }
        }

        globalUpdateManager.instance.registerUpdateDg(ToUpdate);
    }
Пример #6
0
    public void init()
    {
        floorDatas = new floorData[100, 100];
        for (int y = 0; y < 100; y++)
        {
            for (int x = 0; x < 100; x++)
            {
                floorDatas[x, y] = new floorData();
            }
        }

        globalUpdateManager.instance.registerUpdateDg(ToUpdate);
    }
Пример #7
0
    void smellSystem()
    {
        //氣味系統 試作
        floorData curFloorData = gameModel.instance.getFloorDatas(InMapV3Pos);

        if (!isFriendly)
        {
        }
        else
        {
            if (!EnemyAnt)
            {
                //如果發現有敵人氣息就展開調查
                if (curFloorData.floorSmell.enemySmell > 0)
                {
                    Vector2Int[] nexttoPos =
                    {
                        new Vector2Int(InMapV3Pos.x + 1, InMapV3Pos.y),
                        new Vector2Int(InMapV3Pos.x - 1, InMapV3Pos.y),
                        new Vector2Int(InMapV3Pos.x,     InMapV3Pos.y + 1),
                        new Vector2Int(InMapV3Pos.x,     InMapV3Pos.y - 1),
                    };
                    bool keepFindSmell = false;
                    for (int i = 0; i < nexttoPos.Length; i++)
                    {
                        if (gameModel.instance.getFloorDatas(nexttoPos[i]).floorSmell.enemySmell > lasttimeConcentration)
                        {
                            //把最終目的地改成氣息所在地
                            lasttimeConcentration = gameModel.instance.getFloorDatas(InMapV3Pos).floorSmell.enemySmell;
                            gameObject.GetComponent <SpriteRenderer>().color = new Color(0.5f, 1f, 0.5f);
                            keepFindSmell = true;

                            Destination = new Vector2Int(nexttoPos[i].x - 50, nexttoPos[i].y - 50);
                        }
                    }
                    if (!keepFindSmell)
                    {
                        //lost target
                        gameObject.GetComponent <SpriteRenderer>().color = new Color(0, 0, 0);
                    }
                }
            }
        }
    }
Пример #8
0
    void CompareOthersMiningPathAndChooseBetterOne()
    {
        if (antMiningActivity != AntMiningActivityState.none)
        {
            return;
        }

        // if (antMiningActivity == AntMiningActivityState.returnToBase) {
        floorData curFloorData = gameModel.instance.getFloorDatas(InMapV3Pos);

        //ants_FollowMinePath
        for (int i = 0; i < curFloorData.ants.Count; i++)
        {
            MinerAnt item = curFloorData.ants[i].gameObject.GetComponent <MinerAnt>();
            if (!item)
            {
                break;
            }

            WalkingPath itemWalkingPath = item.pathRecord;
            if (itemWalkingPath.path.Count <= 0)
            {
                break;
            }

            /*
             * if (item.antMiningActivity != AntMiningActivityState.followTheMinePath) {
             *  continue;
             * }
             * if (item.pathRecord.serialNumber != pathRecord.serialNumber) {
             *  continue;
             * }
             */

            if ((itemWalkingPath.path.Count) < (pathRecord.path.Count))
            {
                //如果比較目標的掘礦路徑更為短 就偷他的
                TranPathInfo(item);
            }
        }
        // }
    }
Пример #9
0
    //更新坐標
    public virtual void updateObjectMapInformation()
    {
        //移除與註冊
        floorData oldFloorData = gameModel.instance.getFloorDatas(InMapV3Pos);

        oldFloorData.UnregisterAntData(this, isFriendly);
        if (randWalkSmellRecord)
        {
            oldFloorData.UnregisterRandWalkAntData(this);
            randWalkSmellRecord = false;
        }
        InMapV3Pos = gameModel.instance.charWorldToMapV3(_transform);

        floorData newFloorData = gameModel.instance.getFloorDatas(InMapV3Pos);

        newFloorData.RegisterAntData(this, isFriendly);
        if (antActivity == AntActivityState.WalkingAround)
        {
            newFloorData.RegisterRandWalkAntData(this);
            randWalkSmellRecord = true;
        }
    }
Пример #10
0
    void Awake()
    {
        //如果是新开游戏,初始化
        if (player.isNewGame)
        {
            //第一层数据初始化
            #region
            floorData f1 = new floorData();
            //怪物初始化
            f1.enemylist.Add(new enemyObject(new int[] { 1, 0 }, 1));
            f1.enemylist.Add(new enemyObject(new int[] { 5, 8 }, 1));
            f1.enemylist.Add(new enemyObject(new int[] { 7, 5 }, 9));
            f1.enemylist.Add(new enemyObject(new int[] { 7, 2 }, 8));
            f1.enemylist.Add(new enemyObject(new int[] { 8, 3 }, 8));
            f1.enemylist.Add(new enemyObject(new int[] { 7, 3 }, 6));
            f1.enemylist.Add(new enemyObject(new int[] { 8, 9 }, 13));
            f1.enemylist.Add(new enemyObject(new int[] { 10, 2 }, 1));
            f1.enemylist.Add(new enemyObject(new int[] { 10, 3 }, 2));
            f1.enemylist.Add(new enemyObject(new int[] { 10, 4 }, 1));
            f1.enemylist.Add(new enemyObject(new int[] { 3, 2 }, 3));
            f1.enemylist.Add(new enemyObject(new int[] { 2, 5 }, 4));
            f1.enemylist.Add(new enemyObject(new int[] { 1, 5 }, 4));
            f1.enemylist.Add(new enemyObject(new int[] { 0, 5 }, 3));
            f1.enemylist.Add(new enemyObject(new int[] { 3, 5 }, 2));
            f1.enemylist.Add(new enemyObject(new int[] { 3, 4 }, 1));
            f1.enemylist.Add(new enemyObject(new int[] { 3, 3 }, 2));
            f1.enemylist.Add(new enemyObject(new int[] { 2, 7 }, 5));
            f1.enemylist.Add(new enemyObject(new int[] { 3, 9 }, 6));
            f1.enemylist.Add(new enemyObject(new int[] { 2, 10 }, 6));
            f1.enemylist.Add(new enemyObject(new int[] { 2, 8 }, 7));
            f1.enemylist.Add(new enemyObject(new int[] { 1, 9 }, 7));
            f1.enemylist.Add(new enemyObject(new int[] { 1, 7 }, 7));
            f1.enemylist.Add(new enemyObject(new int[] { 0, 8 }, 4));
            f1.enemylist.Add(new enemyObject(new int[] { 0, 10 }, 5));
            f1.enemylist.Add(new enemyObject(new int[] { 3, 7 }, 7));
            f1.enemylist.Add(new enemyObject(new int[] { 3, 8 }, 7));
            f1.enemylist.Add(new enemyObject(new int[] { 1, 10 }, 6));

            //门初始化
            f1.doorlist.Add(new doorObject("yellow", new int[] { 8, 8 }));
            f1.doorlist.Add(new doorObject("red", new int[] { 6, 5 }));
            f1.doorlist.Add(new doorObject("yellow", new int[] { 4, 2 }));
            f1.doorlist.Add(new doorObject("blue", new int[] { 2, 6 }));

            //物品初始化
            f1.wupinglist.Add(new wupingObject(new int[] { 0, 2 }, wupingType.yellowKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 8, 2 }, wupingType.Swordlevel_1));
            f1.wupinglist.Add(new wupingObject(new int[] { 7, 4 }, wupingType.bigHp));
            f1.wupinglist.Add(new wupingObject(new int[] { 8, 5 }, wupingType.Atkup));
            f1.wupinglist.Add(new wupingObject(new int[] { 8, 4 }, wupingType.blueKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 9, 9 }, wupingType.yellowKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 9, 10 }, wupingType.yellowKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 10, 9 }, wupingType.redKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 10, 10 }, wupingType.blueKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 8, 10 }, wupingType.Atkup));
            f1.wupinglist.Add(new wupingObject(new int[] { 7, 10 }, wupingType.Defup));
            f1.wupinglist.Add(new wupingObject(new int[] { 7, 9 }, wupingType.smallHp));
            f1.wupinglist.Add(new wupingObject(new int[] { 2, 2 }, wupingType.smallHp));
            f1.wupinglist.Add(new wupingObject(new int[] { 1, 2 }, wupingType.smallHp));
            f1.wupinglist.Add(new wupingObject(new int[] { 2, 3 }, wupingType.yellowKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 1, 3 }, wupingType.yellowKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 0, 3 }, wupingType.blueKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 0, 4 }, wupingType.redKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 1, 4 }, wupingType.Atkup));
            f1.wupinglist.Add(new wupingObject(new int[] { 2, 4 }, wupingType.Atkup));
            f1.wupinglist.Add(new wupingObject(new int[] { 3, 10 }, wupingType.redKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 0, 7 }, wupingType.yellowKey));
            f1.wupinglist.Add(new wupingObject(new int[] { 1, 8 }, wupingType.smallHp));
            f1.wupinglist.Add(new wupingObject(new int[] { 0, 9 }, wupingType.Atkup));
            f1.wupinglist.Add(new wupingObject(new int[] { 2, 9 }, wupingType.Defup));

            //层玩家初始位置初始化
            f1.init   = new int[] { 5, 10 };
            f1.initUp = new int[] { 1, 0 };

            floorDataList.Add(f1);
            #endregion
            //第二层数据初始化
            #region
            floorData f2 = new floorData();

            //怪物初始化
            f2.enemylist.Add(new enemyObject(new int[] { 1, 0 }, 3));
            f2.enemylist.Add(new enemyObject(new int[] { 7, 0 }, 3));
            f2.enemylist.Add(new enemyObject(new int[] { 9, 0 }, 5));
            f2.enemylist.Add(new enemyObject(new int[] { 6, 1 }, 3));
            f2.enemylist.Add(new enemyObject(new int[] { 8, 1 }, 5));
            f2.enemylist.Add(new enemyObject(new int[] { 10, 1 }, 6));
            f2.enemylist.Add(new enemyObject(new int[] { 1, 2 }, 5));
            f2.enemylist.Add(new enemyObject(new int[] { 4, 2 }, 4));
            f2.enemylist.Add(new enemyObject(new int[] { 7, 2 }, 5));
            f2.enemylist.Add(new enemyObject(new int[] { 9, 2 }, 5));
            f2.enemylist.Add(new enemyObject(new int[] { 8, 3 }, 4));
            f2.enemylist.Add(new enemyObject(new int[] { 1, 4 }, 5));
            f2.enemylist.Add(new enemyObject(new int[] { 0, 4 }, 4));
            f2.enemylist.Add(new enemyObject(new int[] { 2, 4 }, 4));
            f2.enemylist.Add(new enemyObject(new int[] { 1, 5 }, 4));
            f2.enemylist.Add(new enemyObject(new int[] { 7, 5 }, 2));
            f2.enemylist.Add(new enemyObject(new int[] { 0, 6 }, 3));
            f2.enemylist.Add(new enemyObject(new int[] { 1, 6 }, 3));
            f2.enemylist.Add(new enemyObject(new int[] { 2, 6 }, 3));
            f2.enemylist.Add(new enemyObject(new int[] { 7, 6 }, 1));
            f2.enemylist.Add(new enemyObject(new int[] { 4, 7 }, 1));
            f2.enemylist.Add(new enemyObject(new int[] { 4, 8 }, 2));
            f2.enemylist.Add(new enemyObject(new int[] { 8, 8 }, 4));
            f2.enemylist.Add(new enemyObject(new int[] { 7, 9 }, 4));
            f2.enemylist.Add(new enemyObject(new int[] { 10, 9 }, 6));
            f2.enemylist.Add(new enemyObject(new int[] { 9, 10 }, 6));

            //门初始化
            f2.doorlist.Add(new doorObject("red", new int[] { 1, 1 }));
            f2.doorlist.Add(new doorObject("yellow", new int[] { 8, 4 }));
            f2.doorlist.Add(new doorObject("yellow", new int[] { 9, 7 }));

            //物品初始化
            f2.wupinglist.Add(new wupingObject(new int[] { 6, 0 }, wupingType.Atkup));
            f2.wupinglist.Add(new wupingObject(new int[] { 8, 0 }, wupingType.yellowKey));
            f2.wupinglist.Add(new wupingObject(new int[] { 7, 1 }, wupingType.blueKey));
            f2.wupinglist.Add(new wupingObject(new int[] { 9, 1 }, wupingType.yellowKey));
            f2.wupinglist.Add(new wupingObject(new int[] { 0, 2 }, wupingType.Atkup));
            f2.wupinglist.Add(new wupingObject(new int[] { 2, 2 }, wupingType.Atkup));
            f2.wupinglist.Add(new wupingObject(new int[] { 6, 2 }, wupingType.blueKey));
            f2.wupinglist.Add(new wupingObject(new int[] { 8, 2 }, wupingType.smallHp));
            f2.wupinglist.Add(new wupingObject(new int[] { 10, 2 }, wupingType.smallHp));
            f2.wupinglist.Add(new wupingObject(new int[] { 0, 3 }, wupingType.Defup));
            f2.wupinglist.Add(new wupingObject(new int[] { 1, 3 }, wupingType.Defup));
            f2.wupinglist.Add(new wupingObject(new int[] { 2, 3 }, wupingType.Defup));
            f2.wupinglist.Add(new wupingObject(new int[] { 6, 3 }, wupingType.Defup));
            f2.wupinglist.Add(new wupingObject(new int[] { 7, 3 }, wupingType.Atkup));
            f2.wupinglist.Add(new wupingObject(new int[] { 9, 3 }, wupingType.Atkup));
            f2.wupinglist.Add(new wupingObject(new int[] { 10, 3 }, wupingType.Defup));
            f2.wupinglist.Add(new wupingObject(new int[] { 0, 5 }, wupingType.normalHp));
            f2.wupinglist.Add(new wupingObject(new int[] { 2, 5 }, wupingType.normalHp));
            f2.wupinglist.Add(new wupingObject(new int[] { 6, 8 }, wupingType.blueKey));
            f2.wupinglist.Add(new wupingObject(new int[] { 7, 8 }, wupingType.yellowKey));
            f2.wupinglist.Add(new wupingObject(new int[] { 9, 8 }, wupingType.Atkup));
            f2.wupinglist.Add(new wupingObject(new int[] { 10, 8 }, wupingType.Atkup));
            f2.wupinglist.Add(new wupingObject(new int[] { 6, 9 }, wupingType.yellowKey));
            f2.wupinglist.Add(new wupingObject(new int[] { 8, 9 }, wupingType.Defup));
            f2.wupinglist.Add(new wupingObject(new int[] { 9, 9 }, wupingType.Defup));
            f2.wupinglist.Add(new wupingObject(new int[] { 7, 10 }, wupingType.smallHp));
            f2.wupinglist.Add(new wupingObject(new int[] { 8, 10 }, wupingType.smallHp));
            f2.wupinglist.Add(new wupingObject(new int[] { 10, 10 }, wupingType.blueKey));

            //层玩家初始位置初始化
            f2.init   = new int[] { 1, 10 };
            f2.initUp = new int[] { 7, 10 };

            floorDataList.Add(f2);
            #endregion
            //第三层数据初始化
            #region
            floorData f3 = new floorData();

            //怪物初始化
            f3.enemylist.Add(new enemyObject(new int[] { 0, 0 }, 1));

            //门初始化
            f3.doorlist.Add(new doorObject("yellow", new int[] { 2, 4 }));

            //物品初始化
            f3.wupinglist.Add(new wupingObject(new int[] { 10, 0 }, wupingType.redKey));

            //层玩家初始位置初始化
            f3.init   = new int[] { 5, 9 };
            f3.initUp = new int[] { 5, 1 };

            floorDataList.Add(f3);
            #endregion
        }
    }
Пример #11
0
    void tellOtherMinerAntIfHaveMine()
    {
        //告知路過的其他螞蟻有好東西
        if (antMiningActivity == AntMiningActivityState.returnToBase)
        {
            floorData curFloorData = gameModel.instance.getFloorDatas(InMapV3Pos);
            if (inventory > 0)
            {
                for (int i = 0; i < curFloorData.ants_RandWalk.Count; i++)
                {
                    MinerAnt item = curFloorData.ants_RandWalk[i].gameObject.GetComponent <MinerAnt>();
                    //如果目標Ant不是礦工單位就不告訴他
                    if (item == null)
                    {
                        continue;
                    }

                    if (item.resistOrder || !item.acceptOrderProbabilityDetermination())
                    {
                        continue;
                    }

                    //如果有其他螞蟻無所事事
                    //就叫他去掘礦
                    item.antActivity       = AntActivityState.miningResource;
                    item.antMiningActivity = AntMiningActivityState.followTheMinePath;
                    item.GetComponent <SpriteRenderer>().color = Color.yellow;

                    //給他全新記錄
                    item.TranPathInfo(this);
                    //startLerpToDestination();
                }
            }
            else
            {
                for (int i = 0; i < curFloorData.ants_FollowMinePath.Count; i++)
                {
                    MinerAnt item = curFloorData.ants_FollowMinePath[i].gameObject.GetComponent <MinerAnt>();
                    //如果目標Ant不是礦工單位就不告訴他
                    if (item == null)
                    {
                        continue;
                    }
                    if (item.pathRecord.serialNumber != pathRecord.serialNumber)
                    {
                        continue;
                    }
                    if (item.antMiningActivity != AntMiningActivityState.followTheMinePath)
                    {
                        continue;
                    }
                    item.antMiningActivity = AntMiningActivityState.returnToBase;
                    item.GetComponent <SpriteRenderer>().color = Color.gray;

                    //給他全新記錄
                    item.pathRecord  = new WalkingPath(pathRecord);
                    item.pathCounter = pathCounter;
                    item.Destination = item.pathRecord.path[item.pathCounter];
                    startLerpToDestination();
                }
            }
        }
    }