Пример #1
0
    public void AttackDraw(MapBoard _mcBoard)
    {
        if (this.IsAttack)
        {
            this.IsAttack = false;
            animator.SetTrigger("AttackTrigger");
            // animator.SetInteger("animation",11);
            animator.Update(0);
            stateInfo = this.animator.GetCurrentAnimatorStateInfo(0);
            StartCoroutine(DelayDamageDraw(stateInfo.length, _mcBoard));
            if (this.IsDamage)
            {
                Invoke("ViewDamage", stateInfo.length / 2f);
            }
        }
        else if (this.IsDamage)
        {
            StartCoroutine(DelayDamage(0.25f, _mcBoard));
            Invoke("ViewDamage", 0.3f);
        }
        else
        {
            gameMaster.GetComponent <GameMaster>().SetCountDownBool();
        }

        // 終了
    }
Пример #2
0
        /// <summary>
        ///     Tworzy panel Grid na podstawie kolekcji Tile[,] zawartej w MapBoard. Stworzony panel dodaje do aktualnego canvas.
        /// </summary>
        /// <param name="board">Obiekt zawierający kolekcję Tile[,].</param>
        private void CreateGrid(MapBoard board)
        {
            var grid = new Grid {
                Width = GameConst.Width, Height = GameConst.Height
            };

            int rows    = board.GetMapSize()[0];
            int columns = board.GetMapSize()[1];

            for (int i = 0; i < rows; ++i)
            {
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
            }

            for (int i = 0; i < columns; ++i)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
            }

            for (int i = 0; i < rows; ++i)
            {
                for (int j = 0; j < columns; ++j)
                {
                    Grid.SetRow(board.GetTile(i, j), i);
                    Grid.SetColumn(board.GetTile(i, j), j);
                    grid.Children.Add(board.GetTile(i, j));
                }
            }

            Field.Children.Add(grid);
        }
Пример #3
0
    // MDAxMTAwMDAxMDEwMDExMDExMDAwMDAwMTAxMDAwMDAxMDAwMDEwMDAwMTAwMDEwMTAwMDAxMTExMTAwMDEwMDAxMDEwMDAxMDAwMTEwMDEwMTAwMDExMDExMTAwMTExMDAxMDAwMTAwMTEwMDAxMTAxMDAwMDEwMTAwMDEwMDAwMDEwMDAwMTAwMDEwMDAwMDAwMDAxMDAwMDAxMDAwMTEwMDAwMDAwMDExMDAwMDEwMDAxMTAwMDAwMDAwMTEwMDAwMTAwMDExMDAwMDAwMDAxMDAwMDAxMDAwMTEwMDAwMDAwMDAxMDAwMDEwMDAxMDAwMDAwMDAwMTEwMDAxMDAwMDEwMDAwMDA=
    void SetCloseToKingEvent(MapBoard _mcBoard)
    {
        Unit myKing = GetKing(this.team, _mcBoard, "KING");

        // Unit myKing = GetKing(this.team);
        // Debug.Log(myKing.xz_position[0]+","+myKing.xz_position[1]+":"+myKing.team);
        int[,] marea = _mcBoard.GetMoveArea(myKing.xz_position[0], myKing.xz_position[1], 4, myKing.team);
        for (int i = 0; i < marea.GetLength(0); i++)
        {
            for (int j = 0; j < marea.GetLength(1); j++)
            {
                if (marea[i, j] < 0 || marea[i, j] == 4)
                {
                    continue;
                }

                // 移動範囲+攻撃範囲に敵 or 味方がいるか
                for (int k = 0; k < myKing.attackRange.GetLength(0); k++)
                {
                    int tmp_i = i + myKing.attackRange[k, 0];
                    int tmp_j = j + myKing.attackRange[k, 1];
                    // 敵との距離でフラグ設定
                    Unit tmp_enemy = _mcBoard.GetMapBoardUnit(tmp_i, tmp_j);
                    if (IsTeamMate(tmp_enemy) == myKing.enemy_team)
                    {
                        SetFlag(Constants.F_CLOSE_TO_F_KING_ENEMY);
                    }
                    else if (IsTeamMate(tmp_enemy) == myKing.team)
                    {
                        SetFlag(Constants.F_CLOSE_TO_F_KING_FRIEND);
                    }
                }
            }
        }
    }
Пример #4
0
    List <Unit> GetTargetEnemys(MapBoard _mcBoard)
    {
        List <Unit> tmp_taeget_enemy = new List <Unit>();

        // attackRange;
        for (int i = 0; i < attackRange.GetLength(0); i++)
        {
            // 攻撃範囲に敵がいるか調べる
            int  tmp_x     = xz_position[0] + attackRange[i, 0];
            int  tmp_z     = xz_position[1] + attackRange[i, 1];
            Unit tmp_mCube = _mcBoard.GetMapBoardUnit(tmp_x, tmp_z);
            // ターゲットならターゲットを攻撃!!
            if (target_position[0] == tmp_x && target_position[1] == tmp_z && IsTeamMate(tmp_mCube) == this.enemy_team)
            {
                tmp_taeget_enemy.Clear();
                tmp_taeget_enemy.Add(tmp_mCube);
                break;
            }
            if (IsTeamMate(tmp_mCube) == this.enemy_team)
            {
                tmp_taeget_enemy.Add(tmp_mCube);
            }
        }
        return(tmp_taeget_enemy);
    }
Пример #5
0
    public void SetATKEvent(MapBoard _mcBoard)
    {
        SetConnectList();
        // イベント取得
        SetDistanceEvent(_mcBoard);

        // 状態遷移
        DoTransition(connectList);
    }
Пример #6
0
    public void SetMEvent(MapBoard _mcBoard)
    {
        SetConnectList();
        // イベントを取得
        SetDistanceEvent(_mcBoard);                             // 周辺の敵,味方を感知
        SetCloseToKingEvent(_mcBoard);                          // 自軍大将周辺の敵,味方を感知

        // 状態遷移
        DoTransition(connectList);
    }
Пример #7
0
    void Awake()
    {
        // ボードの生成 初期化
        board      = Instantiate(boardPrefab) as MapBoard;
        board.name = "Board";

        units      = new List <Unit>();
        move_units = new List <Unit>();
        Timer      = GameObject.Find("Canvas/Timer").GetComponent <Timer>();
    }
Пример #8
0
    private IEnumerator DelayDamage(float waitTime, MapBoard _mcBoard)
    {
        yield return(new WaitForSeconds(waitTime));

        animator.SetTrigger("OnDamageTrigger");
        animator.Update(0);
        stateInfo = this.animator.GetCurrentAnimatorStateInfo(0);
        // ダメージ表示!とダメージエフェクト hp==0なら死亡
        StartCoroutine(DelayDamageDraw(stateInfo.length, _mcBoard));
    }
Пример #9
0
        private void miOpenGame_Click(object sender, System.EventArgs e)
        {
            if (_model != null)
            {
                DialogResult result = MessageBox.Show(this, "Do you wish to discard the current game?" +
                                                      "\n(changes since last save will be lost)", "Confirm", MessageBoxButtons.OKCancel);
                if (result != DialogResult.OK)
                {
                    return;
                }
            }

            GameData gameData = null;

            Stream         stream;
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "Wormhole Saves(*.whs)|*.whs";
            openFileDialog.RestoreDirectory = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                if ((stream = openFileDialog.OpenFile()) != null)
                {
                    IFormatter formatter = new BinaryFormatter();
                    gameData = (GameData)formatter.Deserialize(stream);
                    stream.Close();
                    if (gameData == null)
                    {
                        return;
                    }
                }
            }
            else
            {
                return;
            }

            int NumberOfPlayers = gameData.PlayerList.Count;

            //Create new game with parameters from the New Game dialog
            _model = new GameModel(gameData);
            //number of systems, we'll get
            //this from the new game
            //dialog eventually
            _mapBoard         = new MapBoard(_model.Update(), -1);
            _mapBoard.HexSize = ClientSize.Width / (gameData.DataMap.Width * 2);
            InitializePlayers();

            //miNextTurn.Text = "&Next Turn!";
            miSaveGame.Enabled = true;
            PrepBoard();
            Invalidate();
        }
Пример #10
0
        protected override void HexgridPanel_MouseMove(object sender, MouseEventArgs e)
        {
            var hotHex = MapBoard.HotspotHex;

            base.HexgridPanel_MouseMove(sender, e);
            StatusBarToolStrip.StatusLabelText = string.Format(CustomCoords,
                                                               Properties.Resources.StatusLabelText,
                                                               hotHex, hotHex, hotHex,
                                                               MapBoard.StartHex - hotHex, MapBoard.Path.Match(path => path.TotalCost, () => 0))
                                                 + $"  Elevation: Ground={MapBoard.ElevationGroundASL(hotHex)};"
                                                 + $" Observer={MapBoard.ElevationObserverASL(hotHex)};"
                                                 + $" Target={MapBoard.ElevationTargetASL(hotHex)}";
        }
Пример #11
0
        /// <summary>
        ///     Przygotowanie programu. Stworzenie odpowiednich elementów gry takich jak: gracz, wrogowie, plansze etc.
        /// </summary>
        private void PrepareGame()
        {
            var board = new MapBoard();

            GameParameters.ActualBoard = board;
            CreateGrid(board);

            var enemies = new List <Enemy> {
                new Human(), new Matphys(), new Human()
            };

            GameParameters.Enemies = enemies;

            Player player;

            switch (GameParameters.PlayerType)
            {
            case Enums.PlayerType.Agile:
                player = new AgileBro();
                break;

            case Enums.PlayerType.Fast:
                player = new FastBro();
                break;

            case Enums.PlayerType.Shy:
                player = new ShyBro();
                break;

            default:
                player = new AgileBro();
                break;
            }

            Info.DataContext = player;
            Field.Width      = GameConst.Width;
            Field.Height     = GameConst.Height;

            Field.Children.Add(player);

            foreach (Enemy e in enemies)
            {
                e.PostInitialize();
                Field.Children.Add(e);
            }

            GameParameters.ActualCanvas = Field;
            GameParameters.Id           = 0;
            GameParameters.ActualPlayer = player;
            GameParameters.Enemies      = enemies;
        }
Пример #12
0
        private void Start()
        {
            _enemies      = new List <Enemy>();
            _collectables = new List <Collectable>();
            _board        = GetComponent <MapBoard>();
            _turnHandler  = GetComponent <TurnHandler>();
            _board.onTurn.AddListener(() => Spawn());
            GameObject spPos = new GameObject();

            spPos.transform.position = transform.position;
            _spawnPos      = spPos.transform;
            _spawnPos.name = "Spawned Entities";
            _spawnPos      = spPos.transform;
        }
Пример #13
0
 public void Move(MapBoard _mcBoard)
 {
     // 状態からターゲットの決定
     if (!SetTarget(this.state, _mcBoard))
     {
         Animated(_mcBoard);
         return;
     }
     // target_position = new int[2]{18,9};
     // 移動範囲を表示
     // 移動場所を表示
     // 目的地まで移動
     ViewArea(_mcBoard);
     // 床を元に戻す。
 }
Пример #14
0
    public void Attack(MapBoard _mcBoard)
    {
        List <Unit> taeget_enemys = GetTargetEnemys(_mcBoard);

        if (taeget_enemys.Count == 0)
        {
            return;
        }
        // ダメージ計算をして終了
        Unit target_enemy = GetTargetEnemy(taeget_enemys);

        target_enemy.OnDamage(this.attack);
        this.IsAttack = true;
        transform.LookAt(target_enemy.gameObject.transform);
    }
Пример #15
0
        private void InitView()
        {
            Point offset = Point.Empty;
            int   size   = 25;

            if (_mapBoard != null)
            {
                offset = _mapBoard.Offset;
                size   = _mapBoard.HexSize;
            }
            _mapBoard         = new MapBoard(_gameData, -1);
            _mapBoard.Offset  = offset;
            _mapBoard.HexSize = size;
            this.PrepBoard();
            this.Invalidate();
        }
Пример #16
0
        private void miNewGame_Click(object sender, System.EventArgs e)
        {
            if (_model != null)
            {
                DialogResult result = MessageBox.Show(this, "Do you wish to discard the current game?" +
                                                      "\n(changes since last save will be lost)", "Confirm", MessageBoxButtons.OKCancel);
                if (result != DialogResult.OK)
                {
                    return;
                }
            }

            //create the dialog and show it
            NewGameDialog dlg = new NewGameDialog();

            dlg.ShowDialog(this);
            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }

            int NumberOfPlayers = dlg.NumberOfPlayers;
            int SizeOfMap       = dlg.SizeOfMap;

            if (NumberOfPlayers > _numClients)
            {
                MessageBox.Show("Not enough players are connected");
                return;
            }


            //Create new game with parameters from the New Game dialog
            _model = new GameModel(NumberOfPlayers, SizeOfMap, SizeOfMap, (SizeOfMap) * (SizeOfMap) / 17);
            //number of systems, we'll get
            //this from the new game
            //dialog eventually
            _mapBoard         = new MapBoard(_model.Update(), -1);
            _mapBoard.HexSize = ClientSize.Width / (SizeOfMap * 2);

            InitializePlayers();

            //miNextTurn.Text = "&Next Turn!";
            miSaveGame.Enabled = true;
            PrepBoard();
            Invalidate();
        }
Пример #17
0
    // 状態に応じたターゲットを決める
    public bool SetTarget(int _state, MapBoard _mcBoard)
    {
        Unit _target;

        switch (_state)
        {
        case Constants.S_INIT:
        case Constants.S_START:
        case Constants.S_WAIT:
            _target = null;
            break;

        case Constants.S_ATK_ENEMY:
            _target = GetNearUnit(this.enemy_team);
            break;

        case Constants.S_ATK_KING:
            _target = GetKing(this.enemy_team, _mcBoard, "TARGET");
            break;

        case Constants.S_DEF_KING:
            _target = GetKing(this.team, _mcBoard, "TARGET");
            break;

        case Constants.S_DEF_FRIEND:
            _target = GetNearUnit(this.team);
            break;

        case Constants.S_GETWAY:
            _target = GetNearUnit(this.enemy_team);
            break;

        default:                 // S_START,S_WAIT
            _target = null;
            break;
        }
        if (_target == null)
        {
            return(false);
        }
        // Debug.Log(this.name+"ターゲット="+_target.name);
        target_position[0] = _target.xz_position[0];
        target_position[1] = _target.xz_position[1];
        return(true);
    }
Пример #18
0
    Unit GetKing(string _team, MapBoard _mcBoard, string _text)
    {
        Unit tmp_king = null;

        Unit[,] unit_board = _mcBoard.map_Board_Unit;
        for (int i = 0; i < unit_board.GetLength(0); i++)
        {
            for (int j = 0; j < unit_board.GetLength(1); j++)
            {
                if (unit_board[i, j] == null)
                {
                    continue;
                }
                if (unit_board[i, j].enemy_team == _team)
                {
                    continue;
                }
                if (unit_board[i, j].type == "KING")
                {
                    tmp_king = unit_board[i, j];
                    break;
                }
            }
        }
        if (_text == "KING")
        {
            return(tmp_king);
        }

        // 自分のチームなら,そいつのターゲットを返す。なければそいつ自身を返す
        if (_team == this.team)
        {
            Unit tmp_unit = tmp_king.GetNearUnit(this.enemy_team);
            if (tmp_unit != null)
            {
                tmp_king = tmp_unit;
            }
        }
        return(tmp_king);
    }
Пример #19
0
 void DamageDraw(MapBoard _mcBoard)
 {
     if (!this.IsDamage)
     {
         gameMaster.GetComponent <GameMaster>().SetCountDownBool();
         return;
     }
     this.IsDamage = false;
     if (this.hp <= 0)
     {
         // _mcBoard.SetMapBoard(xz_position[0],xz_position[1],"Empty", null);
         gameMaster.GetComponent <GameMaster>().units.Remove(this);
         // gameMaster.GetComponent<GameMaster>().move_units.Remove(this);
         // ボードから取り除く
         _mcBoard.SetMapBoard(xz_position[0], xz_position[1], null);
         if (this.type == "KING")
         {
             gameMaster.GetComponent <GameMaster>().SetLOSE(this.team + "KING");
         }
         Destroy(this.gameObject);
     }
     gameMaster.GetComponent <GameMaster>().SetCountDownBool();
 }
Пример #20
0
 void ViewAreaClear(MapBoard _mcBoard)
 {
     if (old_marea.GetLength(0) > 0 && old_marea.GetLength(1) > 0)
     {
         for (int i = 0; i < old_marea.GetLength(0); i++)
         {
             for (int j = 0; j < old_marea.GetLength(1); j++)
             {
                 if (old_marea[i, j] < 0)
                 {
                     continue;
                 }
                 if ((i + j) % 2 == 0)
                 {
                     _mcBoard.DrawBlock(i, j, -2);
                 }
                 else
                 {
                     _mcBoard.DrawBlock(i, j, -1);
                 }
             }
         }
     }
 }
Пример #21
0
    void SetDistanceEvent(MapBoard _mcBoard)
    {
        if (sub_enemy_targets == null)
        {
            sub_enemy_targets = new List <Unit>();
        }
        else
        {
            sub_enemy_targets.Clear();
        }
        if (sub_friend_targets == null)
        {
            sub_friend_targets = new List <Unit>();
        }
        else
        {
            sub_friend_targets.Clear();
        }

        int[,] marea = _mcBoard.GetMoveArea(xz_position[0], xz_position[1], this.locomotion, this.team);
        for (int i = 0; i < marea.GetLength(0); i++)
        {
            for (int j = 0; j < marea.GetLength(1); j++)
            {
                if (marea[i, j] < 0 || marea[i, j] == this.locomotion)
                {
                    continue;
                }

                // 移動範囲+攻撃範囲に敵 or 味方がいるか
                for (int k = 0; k < attackRange.GetLength(0); k++)
                {
                    int tmp_i = i + attackRange[k, 0];
                    int tmp_j = j + attackRange[k, 1];
                    // 敵との距離でフラグ設定
                    Unit tmp_enemy = _mcBoard.GetMapBoardUnit(tmp_i, tmp_j);
                    if (IsTeamMate(tmp_enemy) == this.enemy_team)
                    {
                        // Debug.Log(marea[i,j]+":"+tmp_i+","+tmp_j);
                        if (this.state == Constants.S_ATK_KING && tmp_enemy.type == "KING")
                        {
                        }
                        else
                        {
                            SetFlag(Constants.F_E_APPRECIABLE);
                            // 攻撃候補を取得
                            if (!sub_enemy_targets.Contains(tmp_enemy))
                            {
                                sub_enemy_targets.Add(tmp_enemy);
                            }
                        }
                    }
                    else if (IsTeamMate(tmp_enemy) == this.team)
                    {
                        SetFlag(Constants.F_F_APPRECIABLE);
                        // 攻撃候補を取得
                        if (!sub_friend_targets.Contains(tmp_enemy))
                        {
                            sub_friend_targets.Add(tmp_enemy);
                        }
                    }
                }
            }
        }
    }
Пример #22
0
    void TemplateMove(Vector3 _position, float _time, float _delaytime, string _oncomplete, MapBoard _oncompleteparams, GameObject _oncompletetarget)
    {
        Hashtable moveHash = new Hashtable();         // Hashtable

        moveHash.Add("position", _position);
        moveHash.Add("time", _time);
        moveHash.Add("delay", _delaytime);
        moveHash.Add("orienttopath", true);
        moveHash.Add("easeType", "easeInOutQuad");         //linearTween
        // moveHash.Add ("easeType", "linearTween");//linearTween
        if (_oncomplete != "")
        {
            moveHash.Add("oncomplete", _oncomplete);
            moveHash.Add("oncompleteparams", _oncompleteparams);
            moveHash.Add("oncompletetarget", _oncompletetarget);              // オブジェクトを指定
        }
        iTween.MoveTo(this.gameObject, moveHash);                             // そのメソッドを指定s
    }
Пример #23
0
    private IEnumerator DelayDamageDraw(float waitTime, MapBoard _mcBoard)
    {
        yield return(new WaitForSeconds(waitTime));

        DamageDraw(_mcBoard);
    }
Пример #24
0
 void Start()
 {
     _board = GetComponent <MapBoard>();
     SetBoardPoints();
 }
Пример #25
0
 void Animated(MapBoard _mcBoard)
 {
     animator.SetInteger("animation", 1);
     ViewAreaClear(_mcBoard);
     gameMaster.GetComponent <GameMaster>().SetATKEventBool();
 }
Пример #26
0
    public void ViewArea(MapBoard _mcBoard)
    {
        int top_value = SetTopValue(this.state);

        int[] next_position = new int[2] {
            xz_position[0], xz_position[1]
        };

        int[,] marea = _mcBoard.GetMoveArea(xz_position[0], xz_position[1], locomotion, this.team);
        old_marea    = (int[, ])marea.Clone();
        for (int i = 0; i < marea.GetLength(0); i++)
        {
            for (int j = 0; j < marea.GetLength(1); j++)
            {
                if (marea[i, j] >= 0)
                {
                    // 仲間なら飛ばす 自分なら飛ばさない
                    if (IsTeamMate(_mcBoard.GetMapBoardUnit(i, j)) == this.team)
                    {
                        continue;
                    }
                    _mcBoard.DrawBlock(i, j, marea[i, j]);
                    int tmp_dist1 = GetManhattanDistance(new int[2] {
                        i, j
                    }, target_position);
                    int tmp_dist2 = GetManhattanDistance(xz_position, new int[2] {
                        i, j
                    });
                    int tmp_dist = tmp_dist1 * 6 + tmp_dist2;
                    if (IsGoodValue(this.state, top_value, tmp_dist) == 0 && Random.value < 0.5f)
                    {
                        top_value     = tmp_dist;
                        next_position = new int[2] {
                            i, j
                        };
                    }
                    else if (IsGoodValue(this.state, top_value, tmp_dist) == 1)
                    {
                        top_value     = tmp_dist;
                        next_position = new int[2] {
                            i, j
                        };
                    }
                }
            }
        }
        // もしどれも良くないなら
        if (top_value == SetTopValue(this.state))
        {
            next_position[0] = xz_position[0];
            next_position[1] = xz_position[1];
        }

        _mcBoard.SetMapBoard(xz_position[0], xz_position[1], null);
        _mcBoard.DrawBlock(next_position[0], next_position[1], 4);       // min_position = 目的地
        List <string> path = GetPath(marea, next_position[0], next_position[1]);

        if (path.Count > 0)
        {
            float     sum_time     = 0.3f;
            float     play_time    = 0.5f;
            Vector3   now_position = this.gameObject.transform.position;
            Vector3[] path_array   = new Vector3[path.Count];
            for (int i = 0; i < path.Count; i++)
            {
                path_array[i] = now_position;
            }
            for (int i = 0; i < path.Count; i++)
            {
                if (i == 0)
                {
                    path_array[i] += GetRoot(path[i]);
                }
                else
                {
                    path_array[i] = path_array[i - 1] + GetRoot(path[i]);
                }
                play_time += 0.2f;
            }
            _mcBoard.SetMapBoard(xz_position[0], xz_position[1], this);
            animator.SetInteger("animation", 14);
            if (path_array.Length == 1)
            {
                TemplateMove(path_array[0], play_time, sum_time, "Animated", _mcBoard, this.gameObject);
            }
            else
            {
                TemplateMoveArray(path_array, play_time, sum_time, "Animated", _mcBoard, this.gameObject);
            }
        }
        else
        {
            _mcBoard.SetMapBoard(xz_position[0], xz_position[1], this);
            Animated(_mcBoard);
        }
    }