Пример #1
0
    public void Flow(ActionTree actionTree)
    {
        FloorModel.Instance.Flow();

        List <FloorAnimInfo> anims = FloorModel.Instance.anims[0];

        for (int i = 0; i < anims.Count; i++)
        {
            FloorAnimInfo animInfo = anims[i];

            FightFloorItem item = GetItemByRunId(animInfo.floorInfo.runId);
            if (item != null)
            {
                ParallelAction paralle = new ParallelAction();

                Vector2 toPos = PosUtil.GetFightCellPos(animInfo.floorInfo.posX, animInfo.floorInfo.posY);
                paralle.AddNode(new MoveActor((RectTransform)item.transform, new Vector3(toPos.x, toPos.y, 0), 0, 0.3f));

                OrderAction orderAction = new OrderAction();

                orderAction.AddNode(new ScaleActor((RectTransform)item.transform, new Vector3(0.5f, 0.5f, 1), 0.1f));
                orderAction.AddNode(new WaitActor(100));
                orderAction.AddNode(new ScaleActor((RectTransform)item.transform, new Vector3(1, 1, 1), 0.1f));
                paralle.AddNode(orderAction);

                actionTree.AddNode(paralle);
            }
        }
    }
Пример #2
0
    public void MoveInDirection(Vector2 dir)
    {
        PosUtil.CalculatePos(currentTile, map.columns, out tmpX, out tmpY);

        tmpX += (int)dir.x;
        tmpY += (int)dir.x;
    }
Пример #3
0
    private GameObject CreateFgItem(int posX, int posY, int icon)
    {
        if (icon <= 0)
        {
            CellInfo cell = CellModel.Instance.GetCellByPos(posX - BattleModel.Instance.crtBattle.start_x, -posY + BattleModel.Instance.crtBattle.start_y);
            if (cell != null && cell.config != null)
            {
                if (cell.config.id != 10001)
                {
                    return(null);
                }
                else
                {
                    icon = 10302;
                }
            }
            else
            {
                return(null);
            }
        }

        GameObject item = list.NewItem();

        item.name = posX + "_" + posY;

        FightFgItem itemCtr = item.AddComponent <FightFgItem>();

        itemCtr.type = type;
        itemCtr.icon = icon;
        PosUtil.SetCellPos(item.transform, posX, posY);
        return(item);
    }
Пример #4
0
    public void MoveTo(int index, bool animate = false)
    {
        if (!CanMove(index))
        {
            return;
        }

        currentTile = index;

        PosUtil.CalculatePos(index, map.columns, out tmpX, out tmpY);

        tmpX *= (int)tileSize.x;
        tmpY *= -(int)tileSize.y;

        var newPos = new Vector3(tmpX, tmpY, 0);

        if (!animate)
        {
            transform.position = newPos;
        }
        else
        {
            startPos = transform.position;
            endPos   = newPos;
            moveTime = 0;
            moving   = true;
        }
    }
Пример #5
0
    public void InitRoadCrawl()
    {
        CellInfo        centerCell    = CellModel.Instance.GetCellByPos(posX, posY);
        List <CellInfo> cellNeighbors = CellModel.Instance.GetNeighbors(centerCell);
        CellInfo        findCellPoint = null;

        for (int i = 0; i < cellNeighbors.Count; i++)
        {
            CellInfo cellNeighbor = cellNeighbors[i];

            if (cellNeighbor == null)
            {
                continue;
            }

            BattleCellInfo bcellInfo = BattleModel.Instance.crtBattle.GetBattleCellByPos(cellNeighbor.posX, cellNeighbor.posY);
            if (bcellInfo.bg_id != special1)
            {
                continue;
            }

            findCellPoint = cellNeighbor;

            Vector2 fromPos = PosUtil.GetFightCellPos(posX, posY);
            Vector2 toPos   = PosUtil.GetFightCellPos(findCellPoint.posX, findCellPoint.posY);

            rotate = PosUtil.VectorAngle(new Vector2(fromPos.x, fromPos.y), new Vector2(toPos.x, toPos.y)) / FightConst.ROTATE_BASE;

            break;
        }
    }
Пример #6
0
    public FightCoverItem CreateCoverItem(CoverInfo coverInfo)
    {
        if (coverInfo.IsNull())
        {
            return(null);
        }

        GameObject item = list.NewItem();

        item.name = coverInfo.posX + "_" + coverInfo.posY;

        FightCoverItem itemCtr = item.AddComponent <FightCoverItem>();

        itemCtr.type      = type;
        itemCtr.coverInfo = coverInfo;
        itemCtr.icon      = coverInfo.config.icon;
        itemCtr.rate      = coverInfo.rate;
        itemCtr.UpdateTip();
        PosUtil.SetFightCellPos(item.transform, coverInfo.posX, coverInfo.posY);

        if (coverInfo.show_type == CoverShowType.hide)
        {
            itemCtr.gameObject.transform.localScale = new Vector3(0, 1, 1);
        }

        return(itemCtr);
    }
Пример #7
0
    private void CreateHiveItem(int posX, int posY, float scale = 1)
    {
        GameObject item = list.NewItem();

        item.name = posX + "_" + posY;
        PosUtil.SetCellPos(item.transform, posX, posY);
        item.transform.localScale = new Vector3(scale, scale, 1);
    }
Пример #8
0
        /// <summary>
        ///     Used to offset the pixel data of a tile sprite. Set the value which
        ///     is added to all the ints in a requested tile's data when being
        ///     rendered to the ScreenBufferChip.
        /// </summary>
        /// <param name="column">
        ///     The column position of the tile. 0 is the left of the tile map.
        /// </param>
        /// <param name="row">
        ///     The row position of the tile. 0 is the top of the tile map.
        /// </param>
        /// <param name="paletteID">
        ///     A color int offset.
        /// </param>
        public void UpdateTileColorAt(int column, int row, int paletteID)
        {
            PosUtil.CalculateIndex(column, row, columns, out tmpIndex);

            UpdateDataAt(Layer.Palettes, column, row, paletteID);

            Invalidate(tmpIndex);
        }
Пример #9
0
    public void MoveTo(int index)
    {
        PosUtil.CalculatePos(index, map.columns, out tmpX, out tmpY);

        tmpX *= (int)tileSize.x;
        tmpY *= -(int)tileSize.y;

        transform.position = new Vector3(tmpX, tmpY, 0);
    }
Пример #10
0
    public void MoveInDirection(Vector2 dir)
    {
        PosUtil.CalculatePos(currentTile, map.columns, out tmpX, out tmpY);

        tmpX += (int)dir.x;
        tmpY += (int)dir.y;

        PosUtil.CalculateIndex(tmpX, tmpY, map.columns, out tmpIndex);
        MoveTo(tmpIndex, true);
    }
Пример #11
0
    public void ShowLine(CellInfo cellA, CellInfo cellB)
    {
        GameObject item = list.NewItem();

        item.name = cellA.posX + "_" + cellA.posY + "_" + cellB.posX + "_" + cellB.posY;

        PosUtil.SetFightCellPos(item.transform, cellA.posX, cellA.posY);

        item.transform.Rotate(0, 0, PosUtil.VectorAngle(PosUtil.GetFightCellPos(cellA.posX, cellA.posY), PosUtil.GetFightCellPos(cellB.posX, cellB.posY)));
    }
Пример #12
0
    private void InitView()
    {
        musicMute.isOn = AudioModel.Instance.GetIsMute(false);
        soundMute.isOn = AudioModel.Instance.GetIsMute(true);

        PosUtil.SetCellPos(musicMute.transform, -1, 1);
        PosUtil.SetCellPos(soundMute.transform, 0, 1);
        PosUtil.SetCellPos(sortBtn.transform, -1, 0);
        PosUtil.SetCellPos(reviewBtn.transform, 1, 0);
    }
Пример #13
0
    private void InitHoleList(bool playEffect)
    {
        listHole.ClearList();

        int           i;
        SkillHoleItem findNextOpen = null;

        for (i = 1; i <= SkillTempletModel.MAX_LEVEL; i++)
        {
            GameObject item = listHole.NewItem();
            item.name = skillTempletInfo.config.cellId + "_" + i;

            SkillHoleItem itemCtr = item.GetComponent <SkillHoleItem>();
            itemCtr.skillGroupInfo = skillGroupInfo;
            itemCtr.islock         = false;
            itemCtr.ShowName("");
            itemCtr.waitAnim.enabled = false;
            if (i > skillTempletInfo.lv)
            {
                if (findNextOpen == null)
                {
                    findNextOpen             = itemCtr;
                    itemCtr.waitAnim.enabled = true;
                }
                else
                {
                    itemCtr.islock = true;
                }
            }
            else
            {
                if (i > 1)
                {
                    itemCtr.bombImage.color = ColorUtil.GetColor(ColorUtil.MAP_PASS, 0.9f);
                }
            }

            Vector2 pos = SkillTempletModel.Instance.GetHolePos(i, false, skillTempletInfo.config.dir);
            PosUtil.SetCellPos(item.transform, (int)pos.x, (int)pos.y + 1, 1.1f);

            if (i == 1)
            {
                itemCtr.icon = skillTempletInfo.config.cellId;
                itemCtr.bombImage.gameObject.SetActive(false);
            }
            else if (i == skillTempletInfo.lv && playEffect)
            {
                itemCtr.iconImage.gameObject.SetActive(false);
                GameObject effectPrefab = ResModel.Instance.GetPrefab("effect/" + "effect_fireworks");
                GameObject itemEffect   = GameObject.Instantiate(effectPrefab);
                itemEffect.transform.SetParent(itemCtr.transform, false);
                itemEffect.transform.SetParent(transform, true);
            }
        }
    }
Пример #14
0
    void CenterMap(int index)
    {
        var camPos = Camera.main.transform.position;
        var width  = map.columns;

        PosUtil.CalculatePos(index, width, out tmpX, out tmpY);

        camPos.x = tmpX * tileSize.x;
        camPos.y = -tmpY * tileSize.y;
        Camera.main.transform.position = camPos;
    }
Пример #15
0
    public void MoveInDirection(Vector2 dir)
    {
        PosUtil.CalculatePos(currentTile, map.columns, out tmpX, out tmpY);

        tmpX += (int)dir.x;
        tmpY += (int)dir.y;

        PosUtil.CalculateIndex(tmpX, tmpY, map.columns, out tmpIndex);

        Debug.Log("Move to tile " + tmpIndex);
    }
Пример #16
0
    private void CreatTempletItem(SkillGroupInfo info, SkillTempletInfo skillTempletInfo, int index)
    {
        GameObject item = list.NewItem();

        item.name = "skill_" + skillTempletInfo.config.cellId;

        PosUtil.SetCellPos(item.transform, 0, 0);

        SkillTemplet itemCtr = item.GetComponent <SkillTemplet>();

        itemCtr.Init(info, skillTempletInfo);
    }
Пример #17
0
        public static EntityFactory genPlayer(Scene scene, TiledRlStage stage, PosUtil posUtil, TmxMap map)
        {
            var factory = EntityFactory.begin(scene, "player", posUtil);

            return(factory
                   .body(new Vec2i(7, 7), Dir9.S, true, false)
                   .actor(new Engine.Beh.Player(factory.entity), 3)
                   .viewWodi8(Content.Chips.Pochi.Animals.Kuma04)
                   .add(new FovComp(stage, map))
                   .performance(50, 10, 5)
                   .add(new Player()));
        }
Пример #18
0
    private void Filling(FightStadus fightState = FightStadus.move, int waitmillisecond = 0)
    {
        CellModel.Instance.anims = new List <List <CellAnimInfo> >();
        FunMove.Move(false, isDeductStep);
        List <CellMoveInfo> moveAnims = CellModel.Instance.moveAnims;

        rootAction = new OrderAction();
        ParallelAction paralle = new ParallelAction();

        Dictionary <int, int> newStartPos = new Dictionary <int, int>();

        for (int i = 0; i < moveAnims.Count; i++)
        {
            CellMoveInfo cellMoveInfo = moveAnims[i];

            OrderAction orderAction = new OrderAction();
            paralle.AddNode(orderAction);

            FightCellItem item = GetItemByRunId(cellMoveInfo.cellInfo.runId);
            if (item == null)
            {
                item = CreateCellItem(cellMoveInfo.cellInfo).GetComponent <FightCellItem>();
                int xKey = (int)cellMoveInfo.paths[0].x;
                if (newStartPos.ContainsKey(xKey))
                {
                    int preIndex = newStartPos[xKey];
                    newStartPos[xKey] = preIndex - 1;
                }
                else
                {
                    newStartPos.Add(xKey, -1);
                }

                PosUtil.SetFightCellPos(item.transform, xKey, newStartPos[xKey]);
            }

            for (int j = 0; j < cellMoveInfo.paths.Count; j++)
            {
                Vector2 pathPoint = cellMoveInfo.paths[j];
                Vector2 toPos     = PosUtil.GetFightCellPos((int)pathPoint.x, (int)pathPoint.y);
                float   speed     = isDeductStep ? 1750 : 1350;
                orderAction.AddNode(new MoveActor((RectTransform)item.transform, new Vector3(toPos.x, toPos.y, 0), speed));
            }
            FightEffectItem effectItem = effectLayer.GetEffectItemByPos(cellMoveInfo.cellInfo.posX, cellMoveInfo.cellInfo.posY);
            orderAction.AddNode(new PlayCellMoveEndActor(item, effectItem, cellMoveInfo.cellInfo));
        }
        if (waitmillisecond > 0)
        {
            rootAction.AddNode(new WaitActor(waitmillisecond));
        }
        rootAction.AddNode(paralle);
        ExecuteAction(fightState);
    }
Пример #19
0
    private void CreateItem(SkillSeedInfo seed)
    {
        GameObject item = list.NewItem();

        item.name = "skill_" + seed.runId;
        SkillItem itemCtr = item.GetComponent <SkillItem>();

        itemCtr.icon = seed.GetCellIcon();
        itemCtr.SetHideId(seed.GetHideCellId());
        itemCtr.ShowLock(seed.fobid);
        PosUtil.SetCellPos(item.transform, seed.seed_x, seed.seed_y, 1.0f);
    }
Пример #20
0
    //when we visit a Tile we decorate it AndroidJNI also WebCamFlags redecorate the neighbor tiles
    //to have apropriate FogMode
    void VisitTile(int index)
    {
        int column, newX, newY, row = 0;

        //Calculate position of current tile
        PosUtil.CalculatePos(index, map.columns, out tmpX, out tmpY);

        //Half way of the field of view
        var half = Mathf.FloorToInt(viewDistance / 2f);

        //Shifiting the area that we are going to loop all that area
        tmpX -= half;
        tmpY -= half;

        //find total tile to visit
        var total = viewDistance * viewDistance;
        //Calculate the column
        var maxColumns = viewDistance - 1;

        for (int i = 0; i < total; i++)
        {
            //Find the index OperatingSystemFamily Tile int this Area
            column = i % viewDistance;
            newX   = column + tmpX;
            newY   = row + tmpY;
            PosUtil.CalculateIndex(newX, newY, map.columns, out index);

            if (index > -1 && index < map.tiles.Length)
            {
                var tile = map.tiles [index];
                tile.visited = true;

                DecorateTile(index);

                foreach (var neighbor in tile.neighbors)
                {
                    if (neighbor != null)
                    {
                        if (!neighbor.visited)
                        {
                            neighbor.CalculateFoWAutotileID();
                            DecorateTile(neighbor.id);
                        }
                    }
                }
            }
            if (column == maxColumns)
            {
                row++;
            }
        }
    }
Пример #21
0
    public GameObject ShowLine(CellInfo cellA, CellInfo cellB)
    {
        list.ForceChangeItemPrefab(lineItem);
        GameObject item = list.NewItem();

        item.name = cellA.posX + "_" + cellA.posY + "_" + cellB.posX + "_" + cellB.posY;

        PosUtil.SetFightCellPos(item.transform, cellB.posX, cellB.posY);

        item.transform.Rotate(0, 0, PosUtil.VectorAngle(PosUtil.GetFightCellPos(cellB.posX, cellB.posY), PosUtil.GetFightCellPos(cellA.posX, cellA.posY)));

        return(item);
    }
Пример #22
0
    public void CreatePlayer()
    {
        player      = Instantiate(playerPrefab);
        player.name = "Player";
        player.transform.SetParent(mapContainer.transform);

        PosUtil.CalculatePos(map.castleTile.id, map.columns, out tmpX, out tmpY);

        tmpX *= (int)tileSize.x;
        tmpY *= -(int)tileSize.y;

        player.transform.position = new Vector3(tmpX, tmpY, 0);
    }
Пример #23
0
    void Start()
    {
        PlayerModel.Instance.LoadWeaths();
        MapModel.Instance.LoadMaps();
        SkillTempletModel.Instance.LoadSkillTemplets();
        GuideModel.Instance.InitGuide();
        ADModel.Instance.LoadADData();


        PosUtil.SetCellPos(setBtn.transform, 0, -2);

        EventTriggerListener.Get(startBtn.gameObject).onClick = OnClickStart;
        EventTriggerListener.Get(setBtn.gameObject).onClick   = OnSetClick;
    }
Пример #24
0
    private FightEffectItem CreateEffectItem(int posX, int posY)
    {
        list.ForceChangeItemPrefab(effectItem);
        GameObject item = list.NewItem();

        FightEffectItem itemCtr = item.AddComponent <FightEffectItem>();

        PosUtil.SetFightCellPos(item.transform, posX, posY);
        itemCtr.control_x = posX;
        itemCtr.control_y = posY;
        item.name         = itemCtr.control_x + "_" + itemCtr.control_y;

        return(itemCtr);
    }
Пример #25
0
    void VisitTile(int index)
    {
        int column, newX, newY, row = 0;

        PosUtil.CalculatePos(index, map.columns, out tmpX, out tmpY);

        var half = Mathf.FloorToInt(distance / 2f);

        tmpX -= half;
        tmpY -= half;

        var total      = distance * distance;
        var maxColumns = distance - 1;

        for (int i = 0; i < total; i++)
        {
            column = i % distance;

            newX = column + tmpX;
            newY = row + tmpY;

            PosUtil.CalculateIndex(newX, newY, map.columns, out index);

            if (index > -1 && index < map.tiles.Length)
            {
                var tile = map.tiles[index];
                tile.visited = true;
                DecorateTile(index);

                foreach (var neighbor in tile.neighbors)
                {
                    if (neighbor != null)
                    {
                        if (!neighbor.visited)
                        {
                            neighbor.CalculateFoWAutotileID();
                            DecorateTile(neighbor.id);
                        }
                    }
                }
            }

            if (column == maxColumns)
            {
                row++;
            }
        }
    }
Пример #26
0
    private void CreateControlItem(int posX, int posY)
    {
        GameObject item = list.NewItem();

        item.name = posX + "_" + posY;

        FightControlItem itemCtr = item.AddComponent <FightControlItem>();

        PosUtil.SetCellPos(item.transform, posX, posY);
        itemCtr.control_x = posX - BattleModel.Instance.crtBattle.start_x;
        itemCtr.control_y = -posY + BattleModel.Instance.crtBattle.start_y;

        EventTriggerListener.Get(item).onDown  += ItemDownHander;
        EventTriggerListener.Get(item).onEnter += ItemEnterHander;
        //EventTriggerListener.Get(item).onUp += ItemUpHander;
    }
Пример #27
0
    void Awake()
    {
        instance = this;
        Cache();



//美术测试模式下自动设置跟随者和镜头
#if ART_DEBUG
        //跟随者
        if (m_prefab != null && m_ca != null)
        {
            //if (UnityEditor.PrefabUtility.GetPrefabType(m_prefab) == UnityEditor.PrefabType.Prefab)
            if (m_prefab.transform.parent == null && GameObject.Find(m_prefab.name) == null)//如果是预制体,那么创建
            {
                m_prefab = (GameObject)Object.Instantiate(m_prefab);
            }

            Transform t = m_prefab.transform;
            SetFollow(t);
        }
        else
        {
            Debuger.LogError("CameraMgr;相机找不到跟随对象,是否给相机设置跟随对象");
        }

        //设置初始镜头
        GameObject go = GameObject.Find("CameraTriggerManage");
        if (go == null) //没有场景相机触发管理器就用
        {
            if (m_ca != null)
            {
                SetFollowPos(PosUtil.CaleByCamera(m_ca));
            }
            Set(m_curCameraInfo);
        }
        else
        {
            CameraTriggerMgr mgr = go.GetComponent <CameraTriggerMgr>();
            if (m_ca != null)
            {
                SetFollowPos(mgr.CurGroup.m_bornPos);
            }
            mgr.CurGroup.SetGroupActive(true);
        }
#endif
    }
Пример #28
0
    //centerize the Camera on any tile that we give it Touch the method
    void CenterMap(int index)
    {
        var camPos = Camera.main.transform.position;
        var width  = map.columns;



        PosUtil.CalculatePos(index, width, out tmpX, out tmpY);
        camPos.x = tmpX * tileSize.x;
        camPos.y = -tmpY * tileSize.y;

        //Before using position utility
        //camPos.x = (index % width) * tileSize.x;
        //camPos.y = -((index / width) * tileSize.y);

        Camera.main.transform.position = camPos;
    }
Пример #29
0
    override protected void Awake()
    {
        base.Awake();

        smallPrefab          = ResModel.Instance.GetPrefab("prefab/skillmodule/" + "SkillSmallItem");
        smallList.itemPrefab = smallPrefab;

        groupListPrefab      = ResModel.Instance.GetPrefab("prefab/skillmodule/" + "SkillGroupList");
        groupList.itemPrefab = groupListPrefab;

        ScreenSlider.OpenSlid();

        PosUtil.SetUIPos(starButton, 12);
        PosUtil.SetUIPos(bottleButton, 14);
        PromptModel.Instance.SlideEvent = OnSlideEvent;

        GameObject buggerPrefab = ResModel.Instance.GetPrefab("prefab/base/" + "Bugger");
        GameObject buggerItem   = GameObject.Instantiate(buggerPrefab);

        buggerItem.transform.SetParent(buggerPos, false);
        buggerItem.transform.localPosition = new Vector3(0, 1000, 0);
        buggerItem.transform.localScale    = new Vector3(0.9f, 0.9f, 1);
        bugger        = buggerItem.GetComponent <Bugger>();
        bugger.iconId = 10101;
        bugger.AddPos(new BuggerPosInfo(new Vector2(0, 780), new Vector2(0, 680)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(-279, 780), new Vector2(-279, 680)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(279, 780), new Vector2(279, 680)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(-558, 468), new Vector2(-458, 468)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(-558, 312), new Vector2(-458, 312)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(-558, 156), new Vector2(-458, 156)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(-558, 0), new Vector2(-458, 0)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(-558, -156), new Vector2(-458, -156)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(558, 468), new Vector2(458, 468)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(558, 312), new Vector2(458, 312)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(558, 156), new Vector2(458, 156)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(558, 0), new Vector2(458, 0)));
        bugger.AddPos(new BuggerPosInfo(new Vector2(558, -156), new Vector2(458, -156)));

        bugger.Show();

        InitList();

        UpdateUI();

        AudioModel.Instance.PlayMusic("rain");
    }
Пример #30
0
    private void CreateSmallItem(SkillGroupInfo skillTempletGroupInfo, int index)
    {
        GameObject item = smallList.NewItem();

        PosUtil.SetCellPos(item.transform, index - 2, -5);

        item.name = "skill_" + skillTempletGroupInfo.GetGroupId();

        SkillSmallItem itemCtr = item.GetComponent <SkillSmallItem>();

        itemCtr.toggle.group          = smallToggleGroup;
        itemCtr.skillTempletGroupInfo = skillTempletGroupInfo;
        itemCtr.ShowName("");
        itemCtr.icon = skillTempletGroupInfo.GetGroupId();
        EventTriggerListener.Get(item).onClick = OnSmallClick;
        itemCtr.selectTempletEvent            += OnSelectTemplet;
    }