Example #1
0
        public VTile GetTile(VTile tile, Direction direction)
        {
            VTile resultTile = null;

            switch (direction)
            {
            case Direction.left:
                resultTile = GetTile(tile.coordinate.x - 1, tile.coordinate.y);
                break;

            case Direction.right:
                resultTile = GetTile(tile.coordinate.x + 1, tile.coordinate.y);
                break;

            case Direction.leftUp:
                resultTile = GetTile(tile.coordinate.x - ((tile.coordinate.y + 1) % 2), tile.coordinate.y - 1);
                break;

            case Direction.leftDown:
                resultTile = GetTile(tile.coordinate.x - ((tile.coordinate.y + 1) % 2), tile.coordinate.y + 1);
                break;

            case Direction.rightUp:
                resultTile = GetTile(tile.coordinate.x + (tile.coordinate.y % 2), tile.coordinate.y - 1);
                break;

            case Direction.rightDown:
                resultTile = GetTile(tile.coordinate.x + (tile.coordinate.y % 2), tile.coordinate.y + 1);
                break;
            }
            return(resultTile);
        }
Example #2
0
    void LateUpdate()
    {
        VTile      t = tile.GetTile();
        VLayer     l = t.GetLayer(layerIndex);
        VAnimation a = t.GetAnimation(animationIndex);

        bool active = layerIndex == t.GetLayerIndex() && animationIndex == t.GetAnimationIndex() && frameIndex == t.GetFrameIndex();

        cachedVChunk = t.GetChunk(layerIndex, animationIndex, frameIndex);

        if (GetChunk().IsDirty() || t.GetPalette().IsDirty() || l.IsDirty() || a.IsDirty())
        {
            Refresh();
        }
        bool visible = l.GetVisible() && animationIndex == t.GetAnimationIndex() && frameIndex == t.GetFrameIndex();

        gameObject.layer = (visible && (active || (!l.GetOutline() && !l.GetTransparent()))) ? 10 : 0;
        if (Tool.editing && active)
        {
            visible = false;
        }
        if (mr)
        {
            mr.enabled = visible;
        }
    }
Example #3
0
        private void LoopSearch(VTile vTile)
        {
            if (!vTile.isRoad)
            {
                return;
            }
            if (!vTile.isChecked)
            {
                vTile.isChecked = true;
                tiles.Add(vTile);
            }
            if (vTile.movingPower <= 0 || vTile.isAllCost)
            {
                return;
            }
            List <Vector2Int> coordinates = Global.mapSearch.GetNeighboringCoordinates(vTile.coordinate);

            foreach (Vector2Int vec in coordinates)
            {
                VTile tile = Global.tileUnits[vec.y][vec.x];
                if (tile.isChecked && tile.movingPower >= vTile.movingPower)
                {
                    continue;
                }
                int cost = 1;
                tile.movingPower = vTile.movingPower - cost;
                //Debug.LogError("tile.movingPower = " + tile.movingPower + ", vTile.movingPower="+ vTile.movingPower);
                LoopSearch(tile);
            }
        }
Example #4
0
        public System.Collections.IEnumerator OnBoutFixedDamage(MCharacter mCharacter, Model.Master.MSkill skill, List <VCharacterBase> characters)
        {
            TileMap mapSearch = Global.mapSearch;

            Manager.BattleCharactersManager charactersManager = Global.charactersManager;
            VTile targetTile = mapSearch.GetTile(mCharacter.coordinate);

            foreach (VCharacter child in characters)
            {
                VTile tile = mapSearch.GetTile(child.mCharacter.coordinate);
                if (mapSearch.GetDistance(targetTile, tile) <= skill.radius)
                {
                    int hert = skill.strength;
                    if (child.hp - hert <= 0)
                    {
                        hert = child.hp - 1;
                    }
                    Model.Battle.MDamageParam arg = new Model.Battle.MDamageParam(-hert);
                    child.SendMessage(CharacterEvent.OnDamage.ToString(), arg);
                }
            }
            while (charactersManager.HasDynamicCharacter())
            {
                yield return(new UnityEngine.WaitForEndOfFrame());
            }
        }
Example #5
0
        public void MoveAfterAttack()
        {
            List <VTile> vTiles = cBattlefield.tilesManager.CurrentMovingTiles;
            VTile        vTile  = cBattlefield.mapSearch.GetTile(mCharacter.CoordinateX, mCharacter.CoordinateY);
            VTile        fTile  = cBattlefield.mapSearch.GetTile(cBattlefield.manager.oldCoordinate[0], cBattlefield.manager.oldCoordinate[1]);

            vTiles.Sort((a, b) => {
                int vA = cBattlefield.mapSearch.GetDistance(a, vTile);
                int vB = cBattlefield.mapSearch.GetDistance(b, vTile);
                if (vA != vB)
                {
                    return(vB - vA);
                }
                int fA = cBattlefield.mapSearch.GetDistance(a, fTile);
                int fB = cBattlefield.mapSearch.GetDistance(b, fTile);
                return(fA - fB);
            });
            vTile = vTiles[0];
            if (cBattlefield.charactersManager.GetCharacter(vTile.Index) == null)
            {
                cBattlefield.manager.ClickMovingNode(vTile.Index);
            }
            else
            {
                cBattlefield.StartCoroutine(cBattlefield.manager.ActionOverNext());
            }
        }
Example #6
0
    public void AddPenguin(string tileID, GamePenguin.PenguinColor color)
    {
        List <VPenguin> penguinList;

        VTile tile = tileTable[tileID];

        tile.IsPenguinHere = true;

        VPenguin newPenguin = ScriptableObject.CreateInstance <VPenguin>();

        newPenguin.currTile = tileID;
        newPenguin.lastTile = tileID;
        newPenguin.numFish  = 0;
        newPenguin.isActive = true;

        // Check that color already exists in table, if not, initialize it
        //
        if (!tablePlayerPenguins.ContainsKey(color))
        {
            penguinList = new List <VPenguin>();

            tablePlayerPenguins.Add(color, penguinList);
        }
        else
        {
            penguinList = tablePlayerPenguins[color];
        }

        // Add new penguin to list for player
        //
        penguinList.Add(newPenguin);
    }
Example #7
0
        void CreateScriptableObjectMasterMapRun()
        {
            List <int> tileIds = new List <int>();

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    Transform trans = tilesLayer.transform.Find("Tile_" + (i + 1) + "_" + (j + 1));
                    VTile     vTile = trans.GetComponent <VTile>();
                    tileIds.Add(vTile.mTile.id);
                }
            }

            var  asset = ScriptableObject.CreateInstance <MapAsset>();
            MMap map   = new MMap();

            map.tile_ids = tileIds.ToArray();
            map.width    = width;
            map.height   = height;
            asset.map    = map;
            Debug.LogError("CreateAsset Map:" + setId);
            UnityEditor.AssetDatabase.CreateAsset(asset, string.Format(scriptableMapsPath, setId));
            UnityEditor.AssetDatabase.Refresh();
            Debug.Log("CreateScriptableObjectMasterScenarioRun complete");
        }
Example #8
0
        public void MoveAfterAttack()
        {
            BattleCharactersManager charactersManager = Global.charactersManager;
            TileMap            mapSearch    = Global.mapSearch;
            BattleTilesManager tilesManager = Global.battleManager.tilesManager;
            List <VTile>       vTiles       = tilesManager.currentMovingTiles;
            VTile vTile = mapSearch.GetTile(mCharacter.coordinate);
            VTile fTile = mapSearch.GetTile(Global.battleManager.oldCoordinate);

            vTiles.Sort((a, b) => {
                int vA = mapSearch.GetDistance(a, vTile);
                int vB = mapSearch.GetDistance(b, vTile);
                if (vA != vB)
                {
                    return(vB - vA);
                }
                int fA = mapSearch.GetDistance(a, fTile);
                int fB = mapSearch.GetDistance(b, fTile);
                return(fA - fB);
            });
            vTile = vTiles[0];
            if (charactersManager.GetCharacter(vTile.coordinate) == null)
            {
                Global.battleManager.ClickMovingNode(vTile.coordinate);
            }
            else
            {
                AppManager.CurrentScene.StartCoroutine(Global.battleManager.ActionOverNext());
            }
        }
Example #9
0
        public void ShowCharacterSkillArea(MCharacter mCharacter)
        {
            //技能攻击扩展范围
            List <int[]> distances = mCharacter.SkillDistances;

            distances.Add(mCharacter.CurrentSkill == null ? new int[] { 0, 0 } : mCharacter.CurrentSkill.Master.distance);
            //int[] distance = mCharacter.CurrentSkill == null ? new int[]{0,0} : mCharacter.CurrentSkill.Master.distance;
            int maxDistance = 0;

            foreach (int[] distance in distances)
            {
                if (distance[1] > maxDistance)
                {
                    maxDistance = distance[1];
                }
            }
            currentAttackTiles = cBattlefield.breadthFirst.Search(mCharacter, maxDistance);
            VTile characterTile = currentAttackTiles.Find(v => v.CoordinateX == mCharacter.CoordinateX && v.CoordinateY == mCharacter.CoordinateY);

            currentAttackTiles = currentAttackTiles.FindAll((tile) => {
                int length = cBattlefield.mapSearch.GetDistance(tile, characterTile);
                return(distances.Exists(d => length >= d[0] && length <= d[1]));
            });
            if (mCharacter.CurrentSkill == null)
            {
                return;
            }
            vBaseMap.ShowAttackTiles(currentAttackTiles);
            if (mCharacter.Belong == Belong.self && !mCharacter.ActionOver)
            {
                ShowCharacterSkillTween(mCharacter, currentAttackTiles);
            }
        }
Example #10
0
 private void CalculationGHF(VTile node)
 {
     node.H = cBaseMap.mapSearch.GetDistance(node, endNode);
     node.F = node.G + node.H;
     //node.tileName.text = node.G + "," + node.H + "," + node.F;
     //node.tileName.gameObject.SetActive(true);
 }
Example #11
0
    static void AddFace(VTile tile, int x, int y, int z, Vector3 normal, bool subMesh)
    {
        normals.Add(normal);
        normals.Add(normal);
        normals.Add(normal);
        normals.Add(normal);

        tris.Add(v + 0);
        tris.Add(v + 1);
        tris.Add(v + 2);

        tris.Add(v + 0);
        tris.Add(v + 2);
        tris.Add(v + 3);

        v += 4;

        int i = GetIndex(tile, x, y, z);

        Vector2 uv = new Vector2(i + 0.5f, 0.5f) / 256f;

        uvs.Add(uv);
        uvs.Add(uv);
        uvs.Add(uv);
        uvs.Add(uv);
    }
Example #12
0
        /// <summary>
        /// 恢复量=
        /// </summary>
        /// <param name="attackCharacter">Attack character.</param>
        /// <param name="targetCharacter">Target character.</param>
        public int Heal(MCharacter attackCharacter, MCharacter targetCharacter, VTile tile = null, VTile targetTile = null)
        {
            MSkill skill = attackCharacter.CurrentSkill;

            App.Model.Master.MSkill skillMaster = skill.Master;
            return(1 + attackCharacter.Level + attackCharacter.Ability.MagicAttack * skillMaster.strength);
        }
Example #13
0
        public VTile GetTile(VTile tile, Direction direction)
        {
            VTile resultTile = null;

            switch (direction)
            {
            case Direction.left:
                resultTile = GetTile(tile.CoordinateX - 1, tile.CoordinateY);
                break;

            case Direction.right:
                resultTile = GetTile(tile.CoordinateX + 1, tile.CoordinateY);
                break;

            case Direction.leftUp:
                resultTile = GetTile(tile.CoordinateX - ((tile.CoordinateY + 1) % 2), tile.CoordinateY - 1);
                break;

            case Direction.leftDown:
                resultTile = GetTile(tile.CoordinateX - ((tile.CoordinateY + 1) % 2), tile.CoordinateY + 1);
                break;

            case Direction.rightUp:
                resultTile = GetTile(tile.CoordinateX + (tile.CoordinateY % 2), tile.CoordinateY - 1);
                break;

            case Direction.rightDown:
                resultTile = GetTile(tile.CoordinateX + (tile.CoordinateY % 2), tile.CoordinateY + 1);
                break;
            }
            return(resultTile);
        }
Example #14
0
        public List <VTile> GetTiles()
        {
            var   ret = new List <VTile>();
            VTile t   = null;

            if (StartTile.Col == Game.BoardSize - 1)
            {
                t = StartTile.LeftTile.RightTile;
            }
            else
            {
                t = StartTile.RightTile.LeftTile;
            }

            ret.Add(t);
            for (int i = 1; i < Text.Length; i++)
            {
                if (t != null)
                {
                    if (Direction == MovementDirection.Across)
                    {
                        t = t.RightTile;
                    }
                    else
                    {
                        t = t.DownTile;
                    }
                }
                if (t != null)
                {
                    ret.Add(t);
                }
            }
            return(ret);
        }
Example #15
0
        private void SearchInit(MCharacter mCharacter, bool obstacleEnable = false)
        {
            foreach (VTile tile in vBaseMap.tileUnits)
            {
                tile.SearchInit();
            }
            if (cBattlefield == null || !obstacleEnable)
            {
                return;
            }
            foreach (MCharacter character in mBaseMap.Characters)
            {
                if (character.Hp == 0 || character.IsHide || cBattlefield.charactersManager.IsSameCharacter(mCharacter, character))
                {
                    continue;
                }
                VTile tile = cBattlefield.mapSearch.GetTile(character.CoordinateX, character.CoordinateY);
                if (cBattlefield.charactersManager.IsSameBelong(mCharacter.Belong, character.Belong))
                {
                    continue;
                }
                tile.IsRoad = false;

                List <Vector2> coordinates = cBattlefield.mapSearch.GetNeighboringCoordinates(baseMapMaster.GetCoordinateFromIndex(tile.Index));
                foreach (Vector2 vec in coordinates)
                {
                    VTile childTile = vBaseMap.tileUnits[(int)vec.y * vBaseMap.mapWidth + (int)vec.x];
                    if (childTile.CoordinateX == mCharacter.CoordinateX && childTile.CoordinateY == mCharacter.CoordinateY)
                    {
                        continue;
                    }
                    childTile.IsAllCost = true;
                }
            }
        }
Example #16
0
        public int GetDistance(VTile tile1, VTile tile2)
        {
            return(GetDistance(tile1.CoordinateX, tile1.CoordinateY, tile2.CoordinateX, tile2.CoordinateY));

            /*if (tile2.CoordinateY == tile1.CoordinateY)
             * {
             *  return Mathf.Abs(tile2.CoordinateX - tile1.CoordinateX);
             * }
             * int distance = 0;
             * int directionY = tile2.CoordinateY > tile1.CoordinateY ? 1 : -1;
             * int x = tile1.CoordinateX;
             * int y = tile1.CoordinateY;
             * do{
             *  distance += 1;
             *  if(tile2.CoordinateX != x){
             *      if(y % 2 == 0){
             *          if(tile2.CoordinateX < x){
             *              x -= 1;
             *          }
             *      }else{
             *          if(tile2.CoordinateX > x){
             *              x += 1;
             *          }
             *      }
             *  }
             *  y += directionY;
             * }while (tile2.CoordinateY != y);
             * return Mathf.Abs(tile2.CoordinateX - x) + distance;*/
        }
Example #17
0
        private void LoopSearch(VTile vTile)
        {
            if (!vTile.IsRoad)
            {
                return;
            }
            if (!vTile.IsChecked)
            {
                vTile.IsChecked = true;
                tiles.Add(vTile);
            }
            if (vTile.MovingPower <= 0 || vTile.IsAllCost)
            {
                return;
            }
            List <Vector2> coordinates = cBaseMap.mapSearch.GetNeighboringCoordinates(baseMapMaster.GetCoordinateFromIndex(vTile.Index));

            foreach (Vector2 vec in coordinates)
            {
                VTile tile = vBaseMap.tileUnits[(int)vec.y * vBaseMap.mapWidth + (int)vec.x];
                if (tile.IsChecked && tile.MovingPower >= vTile.MovingPower)
                {
                    continue;
                }
                int cost = 1;
                tile.MovingPower = vTile.MovingPower - cost;
                LoopSearch(tile);
            }
        }
Example #18
0
        /// <summary>
        /// 特技导致武将状态改变
        /// </summary>
        /// <param name="skill">Skill.</param>
        private void AddAidToCharacter(App.Model.Master.MSkillEffect mSkillEffect, MCharacter[] targetCharacters)
        {
            List <int> aids  = mSkillEffect.strategys.ToList();
            int        index = 0;
            List <App.Model.Master.MStrategy> strategys = new List <App.Model.Master.MStrategy>();

            while (index++ < mSkillEffect.count)
            {
                int i = UnityEngine.Random.Range(0, aids.Count - 1);
                App.Model.Master.MStrategy strategy = StrategyCacher.Instance.Get(aids[i]);
                aids.RemoveAt(i);
                strategys.Add(strategy);
            }
            foreach (App.Model.Master.MStrategy strategy in strategys)
            {
                foreach (MCharacter target in targetCharacters)
                {
                    //特效
                    if (strategy.effect_type == StrategyEffectType.aid)
                    {
                        VTile vTile = Global.mapSearch.GetTile(target.coordinate);
                        //cBattle.CreateEffect(strategy.effect, vTile.transform);
                    }
                    else if (strategy.effect_type == StrategyEffectType.status)
                    {
                        VTile vTile = Global.mapSearch.GetTile(target.coordinate);
                        //cBattle.CreateEffect(strategy.effect, vTile.transform);
                    }
                }
            }
            AppManager.CurrentScene.StartCoroutine(AddAidToCharacterComplete(strategys, targetCharacters));
        }
Example #19
0
    /// <summary>
    /// Print current board layout (for debugging)
    /// </summary>
    ///
    public override string ToString()
    {
        int size = GameManager.GetGameManager().dimension;

        string id, sRow, str;
        string idr = "87654321";
        string idc = "abcdefgh";

        str = "";

        for (int row = 0; row < size; row++)
        {
            sRow = idr[row].ToString() + ": |";

            for (int col = 0; col < size - row % 2; col++)
            {
                id = string.Format("{0}{1}", idc[col], idr[row]);

                VTile tile = tileTable[id];

                sRow += tile.tileDesc + "|";
            }

            str += sRow + '\n';
        }

        str += "-----------------------\n";
        str += "_:_|a|b|c|d|e|f|g|h|\n";
        str += colorCurrentPlayer.ToString() + " to move.\n";

        return(str);
    }
Example #20
0
        /// <summary>
        /// 特技导致武将状态改变
        /// </summary>
        /// <param name="skill">Skill.</param>
        private void AddAidToCharacter(App.Model.Master.MSkillEffect mSkillEffect, App.Model.MCharacter[] targetCharacters)
        {
            List <int> aids  = mSkillEffect.strategys.ToList();
            int        index = 0;
            List <App.Model.Master.MStrategy> strategys = new List <App.Model.Master.MStrategy>();

            while (index++ < mSkillEffect.count)
            {
                int i = Random.Range(0, aids.Count - 1);
                App.Model.Master.MStrategy strategy = StrategyCacher.Instance.Get(aids[i]);
                aids.RemoveAt(i);
                strategys.Add(strategy);
            }
            foreach (App.Model.Master.MStrategy strategy in strategys)
            {
                foreach (App.Model.MCharacter target in targetCharacters)
                {
                    //特效
                    if (strategy.effect_type == App.Model.Master.StrategyEffectType.aid)
                    {
                        //this.mCharacter.Target.AddAid(strategy);
                        VTile vTile = this.cBattlefield.mapSearch.GetTile(target.CoordinateX, target.CoordinateY);
                        this.cBattlefield.CreateEffect(strategy.effect, vTile.transform);
                    }
                    else if (strategy.effect_type == App.Model.Master.StrategyEffectType.status)
                    {
                        //this.mCharacter.Target.AddStatus(strategy);
                        VTile vTile = this.cBattlefield.mapSearch.GetTile(target.CoordinateX, target.CoordinateY);
                        this.cBattlefield.CreateEffect(strategy.effect, vTile.transform);
                    }
                }
            }
            cBattlefield.StartCoroutine(AddAidToCharacterComplete(strategys, targetCharacters));
        }
        public static VTile SetDownLetter(this VTile t, char c, Player p, bool Validate)
        {
            if (t != null && t.DownTile != null)
            {
                if (t.DownTile.IsEmpty)
                {
                    t.DownTile.IsValidated = Validate;
                }
                t.DownTile.Letter = Game.Alphabet.Find(a => a.Char == char.ToUpper(c));

                t.IsPlayedByPlayer1 = p.Name == "Player 1";

                if (char.IsLower(c))
                {
                    t.DownTile.FromJoker = true;
                }
                if (t.DownTile.FromJoker)
                {
                    p.Rack.Remove(Game.AlphabetWWFAvecJoker[26]);
                }
                else
                {
                    p.Rack.Remove(Game.Alphabet.Find(a => a.Char == char.ToUpper(c)));
                }
                return(t.DownTile);
            }
            return(null);
        }
Example #22
0
    public static byte[] TileToVox(VTile tile)
    {
        List <byte> data = new List <byte>();

        Add(data, (byte)'V', (byte)'O', (byte)'X', (byte)' ');
        Add(data, System.BitConverter.GetBytes(150));
        Add(data, (byte)'M', (byte)'A', (byte)'I', (byte)'N');
        Add(data, System.BitConverter.GetBytes(0));
        int mainChildSizeIndex = data.Count;

        Add(data, (byte)'S', (byte)'I', (byte)'Z', (byte)'E');
        Add(data, System.BitConverter.GetBytes(12));
        Add(data, System.BitConverter.GetBytes(0));
        Add(data, System.BitConverter.GetBytes(tile.GetWidth()));
        Add(data, System.BitConverter.GetBytes(tile.GetHeight()));
        Add(data, System.BitConverter.GetBytes(tile.GetDepth()));
        Add(data, (byte)'X', (byte)'Y', (byte)'Z', (byte)'I');
        int xyziContentSizeIndex = data.Count;

        Add(data, System.BitConverter.GetBytes(0));
        int numVoxelsIndex = data.Count;
        int numVoxels      = 0;

        for (int x = 0; x < tile.GetWidth(); x++)
        {
            for (int y = 0; y < tile.GetHeight(); y++)
            {
                for (int z = 0; z < tile.GetDepth(); z++)
                {
                    int index = GetIndex(tile, x, y, z);
                    if (index != 0)
                    {
                        Add(data, (byte)x, (byte)(tile.GetHeight() - z - 1), (byte)y, (byte)(255 - index + 1));
                        numVoxels++;
                    }
                }
            }
        }
        data.InsertRange(numVoxelsIndex, System.BitConverter.GetBytes(numVoxels));
        data.InsertRange(xyziContentSizeIndex, System.BitConverter.GetBytes(data.Count - xyziContentSizeIndex - 4));
        Add(data, (byte)'R', (byte)'G', (byte)'B', (byte)'A');
        Add(data, System.BitConverter.GetBytes(256 * 4));
        Add(data, System.BitConverter.GetBytes(0));
        for (int i = 255; i >= 0; i--)
        {
            VColor c;
            if (i >= tile.GetPalette().GetCount())
            {
                c = new VColor(255, 0, 255, 255, 0, 0, 255, 0);
            }
            else
            {
                c = tile.GetPalette().GetColor(i);
            }
            Add(data, c.r, c.g, c.b, c.a);
        }
        data.InsertRange(mainChildSizeIndex, System.BitConverter.GetBytes(data.Count - mainChildSizeIndex));
        return(data.ToArray());
    }
Example #23
0
        private void MoveStart(int index)
        {
            VTile startTile = cBattlefield.mapSearch.GetTile(this.mCharacter.CoordinateX, this.mCharacter.CoordinateY);
            VTile endTile   = cBattlefield.mapSearch.GetTile(index);

            cBattlefield.MapMoveToPosition(this.mCharacter.CoordinateX, this.mCharacter.CoordinateY);
            Holoville.HOTween.Core.TweenDelegate.TweenCallback moveComplete;
            if (cBattlefield.battleMode == CBattlefield.BattleMode.move_after_attack)
            {
                moveComplete = () =>
                {
                    this.mCharacter.CoordinateY = endTile.CoordinateY;
                    this.mCharacter.CoordinateX = endTile.CoordinateX;
                    cBattlefield.MapMoveToPosition(this.mCharacter.CoordinateX, this.mCharacter.CoordinateY);
                    cBattlefield.StartCoroutine(ActionOverNext());
                };
            }
            else
            {
                moveComplete = () =>
                {
                    this.mCharacter.Action = ActionType.idle;
                    cBattlefield.tilesManager.ClearCurrentTiles();
                    cBattlefield.battleMode     = CBattlefield.BattleMode.move_end;
                    this.mCharacter.CoordinateY = endTile.CoordinateY;
                    this.mCharacter.CoordinateX = endTile.CoordinateX;
                    cBattlefield.MapMoveToPosition(this.mCharacter.CoordinateX, this.mCharacter.CoordinateY);
                    cBattlefield.tilesManager.ShowCharacterSkillArea(this.mCharacter);
                    cBattlefield.OpenOperatingMenu();
                };
            }

            List <VTile> tiles = cBattlefield.aStar.Search(this.mCharacter, startTile, endTile);

            this.mCharacter.roadLength = tiles.Count;
            if (tiles.Count > 0)
            {
                cBattlefield.CloseOperatingMenu();
                cBattlefield.tilesManager.ClearCurrentTiles();
                this.mCharacter.Action  = ActionType.move;
                cBattlefield.battleMode = CBattlefield.BattleMode.moving;
                Sequence sequence = new Sequence();
                foreach (VTile tile in tiles)
                {
                    TweenParms tweenParms = new TweenParms().Prop("X", tile.transform.localPosition.x, false).Prop("Y", tile.transform.localPosition.y, false).Ease(EaseType.Linear);
                    if (tile.Index == endTile.Index)
                    {
                        tweenParms.OnComplete(moveComplete);
                    }
                    sequence.Append(HOTween.To(this.mCharacter, 0.5f, tweenParms));
                }
                sequence.Play();
            }
            else
            {
                moveComplete();
            }
        }
Example #24
0
 /// <summary>
 /// 开始动作
 /// </summary>
 /// <returns><c>true</c>, if start run was actioned, <c>false</c> otherwise.</returns>
 /// <param name="vCharacter">Current character.</param>
 private void ActionStartRun(VCharacterBase vCharacter)
 {
     Debug.LogError("ActionStartRun");
     System.Action actionStartEvent = () =>
     {
         //cBattlefield.MapMoveToPosition(currentCharacter.CoordinateX, currentCharacter.CoordinateY);
         //vCharacter.direction = (vCharacter.mCharacter.coordinate.x > vCharacter.mCharacter.target.coordinate.x ? Direction.left : Direction.right);
         vCharacter.direction = Global.mapSearch.GetDirection(vCharacter.mCharacter.coordinate, vCharacter.mCharacter.target.coordinate);
         vCharacter.action    = ActionType.attack;
         App.Model.Master.MSkill skillMaster = vCharacter.mCharacter.currentSkill.master;
         if (!string.IsNullOrEmpty(skillMaster.animation))
         {
             VTile vTile = Global.mapSearch.GetTile(vCharacter.mCharacter.target.coordinate);
             //this.cBattlefield.CreateEffect(skillMaster.animation, vTile.transform);
         }
     };
     if (vCharacter.mCharacter.currentSkill.master.effect.special == SkillEffectSpecial.back_thrust)
     {
         //回马枪
         VTile     currentTile = Global.mapSearch.GetTile(vCharacter.mCharacter.coordinate);
         VTile     targetTile  = Global.mapSearch.GetTile(vCharacter.mCharacter.target.coordinate);
         Direction direction   = Global.mapSearch.GetDirection(targetTile, currentTile);
         VTile     backTile    = Global.mapSearch.GetTile(currentTile, direction);
         if (Global.charactersManager.GetCharacter(backTile.coordinate) != null)
         {
             actionStartEvent();
             return;
         }
         Sequence   sequence   = new Sequence();
         TweenParms tweenParms = new TweenParms()
                                 .Prop("X", backTile.transform.localPosition.x, false)
                                 .Prop("Y", backTile.transform.localPosition.y, false)
                                 .Ease(EaseType.Linear);
         TweenParms tweenParmsTarget = new TweenParms()
                                       .Prop("X", currentTile.transform.localPosition.x, false)
                                       .Prop("Y", currentTile.transform.localPosition.y, false)
                                       .Ease(EaseType.Linear);
         Holoville.HOTween.Core.TweenDelegate.TweenCallback moveComplete = () =>
         {
             vCharacter.mCharacter.coordinate.y        = backTile.coordinate.y;
             vCharacter.mCharacter.coordinate.x        = backTile.coordinate.x;
             vCharacter.mCharacter.target.coordinate.y = currentTile.coordinate.y;
             vCharacter.mCharacter.target.coordinate.x = currentTile.coordinate.x;
             actionStartEvent();
         };
         tweenParms.OnComplete(moveComplete);
         VCharacterBase vTarget = Global.charactersManager.GetVCharacter(vCharacter.mCharacter.target);
         sequence.Insert(0f, HOTween.To(vCharacter, 0.5f, tweenParms));
         sequence.Insert(0f, HOTween.To(vTarget, 0.5f, tweenParmsTarget));
         sequence.Play();
     }
     else
     {
         actionStartEvent();
     }
 }
Example #25
0
        private void SetPath(VTile startNode)
        {
            VTile pathNode = endNode;

            while (pathNode.Index != startNode.Index)
            {
                path.Insert(0, pathNode);
                pathNode = pathNode.ParentNode;
            }
        }
Example #26
0
        private void SetPath(VTile startNode)
        {
            VTile pathNode = endNode;

            while (!pathNode.coordinate.Equals(startNode.coordinate))
            {
                path.Insert(0, pathNode);
                pathNode = pathNode.parentNode;
            }
        }
Example #27
0
 public TextBoxTile(VTile t)
 {
     TileType         = t.TileType;
     Background       = UpdateColor(t);
     Col              = t.Col;
     Ligne            = t.Ligne;
     Letter           = t.Letter;
     WordMultiplier   = t.IsEmpty ? t.WordMultiplier : 1;
     LetterMultiplier = t.IsEmpty ? t.LetterMultiplier : 1;
 }
Example #28
0
    void Awake()
    {
        use        = this;
        tile       = new VTile();
        refPalette = new VPalette();

        width  = tile.GetWidth();
        height = tile.GetHeight();
        depth  = tile.GetDepth();
    }
Example #29
0
        private IEnumerator MoveToNearestTarget()
        {
            BattleCharactersManager charactersManager = Global.charactersManager;
            TileMap            mapSearch    = Global.mapSearch;
            BattleTilesManager tilesManager = Global.battleManager.tilesManager;
            List <VTile>       tileList     = null;

            foreach (MCharacter character in charactersManager.mCharacters)
            {
                if (character.hp == 0 || character.isHide)
                {
                    continue;
                }
                if (charactersManager.IsSameBelong(mCharacter.belong, character.belong))
                {
                    continue;
                }
                VTile        startTile = mapSearch.GetTile(mCharacter.coordinate);
                VTile        endTile   = mapSearch.GetTile(character.coordinate);
                List <VTile> tiles     = Global.aStar.Search(mCharacter, startTile, endTile);
                if (tiles.Count == 0)
                {
                    tiles = Global.aStar.Search(mCharacter, startTile, endTile, charactersManager.mCharacters);
                    if (tiles.Count == 0)
                    {
                        Debug.LogError("MoveToNearestTarget search null");
                        yield return(new WaitForEndOfFrame());
                    }
                }
                if (tileList == null || tileList.Count > tiles.Count)
                {
                    tileList = tiles;
                }
            }
            for (int i = tileList.Count - 1; i >= 0; i--)
            {
                VTile tile = tileList[i];
                if (!tilesManager.IsInMovingCurrentTiles(tile.coordinate))
                {
                    continue;
                }
                MCharacter character = charactersManager.mCharacters.Find(chara => chara.hp > 0 && !chara.isHide && chara.coordinate.Equals(tile.coordinate));
                if (character != null)
                {
                    continue;
                }
                Global.battleManager.ClickMovingNode(tile.coordinate);
                break;
            }
            do
            {
                yield return(new WaitForEndOfFrame());
            }while (Global.battleManager.battleMode == BattleMode.moving);
            yield return(new WaitForEndOfFrame());
        }
Example #30
0
        private void CoordinateYChanged(int oldvalue, int newvalue)
        {
            if (cBaseMap == null)
            {
                return;
            }
            VTile vTile = cBaseMap.mapSearch.GetTile(ViewModel.CoordinateX.Value, newvalue);

            ViewModel.Y.Value         = vTile.transform.localPosition.y;
            sortingGroup.sortingOrder = vTile.Index + 10;
        }