示例#1
0
 private void TimerTick(object sender, EventArgs e)
 {
     if (pr1.Value == 100)
     {
         pr1.Value = 0;
         if (WindowConfig.GameState == WindowConfig.State.Offline)
         {
             Game.ChangeTurn();
             EnemyField.ChangeTurn(this);
         }
         else
         {
             if (OnlineGame.IsMyTurn)
             {
                 EnemyField.SwitchTurn(true);
             }
         }
     }
     else
     {
         if (!IsPaused)
         {
             pr1.Value++;
         }
     }
 }
示例#2
0
    // 復帰
    public void ReCreate()
    {
        List <TroutData> datalist = GlobalDataManager.GetGlobalData().LoadTroutData();

        for (int i = 0; i < datalist.Count; i++)
        {
            Trout2 trout = Instantiate(troutObj, Vector3.zero, Quaternion.Euler(0, 0, 0)) as Trout2;
            trout.ReCreate(datalist[i]);
            trout.name = "MapTrout";
            troutList.Add(trout);
        }
        List <EnemyData> enemylist = GlobalDataManager.GetGlobalData().LoadEnemyDataList();

        Debug.Log("敵を" + enemylist.Count + "体再出現させます。");
        for (int i = 0; i < enemylist.Count; i++)
        {
            EnemyField enemy = Instantiate(enemyObj, enemylist[i].Position, Quaternion.Euler(0, 0, 0)) as EnemyField;
            enemy.Manager = this;
            enemy.Target  = playerOwner.gameObject;
            enemy.FirstAreaCheck();
            enemyList.Add(enemy);
        }
        playerOwner.Manager = this;
        playerOwner.Respawn();
    }
示例#3
0
 public Form1()
 {
     InitializeComponent();
     this.button2.Text   = "Start game";
     this.numOfFour.Text = ""; this.numOfThree.Text = ""; this.numOfTwo.Text = ""; this.numOfOne.Text = "";
     MyField.CreateField(FieldOne);
     EnemyField.CreateField(FieldTwo);
     player = MyField._Player;
     shipDesk(oneDeck, twoDeck, threeDeck, fourDeck, numOfOne, numOfTwo, numOfThree, numOfFour);
 }
示例#4
0
    public void CleanGuardZone(EnemyField field)
    {
        for(int i = 0; i < cards.Count; i++)
        {
            field.AddToDropZone(cards[i], false);
        }
        cards.Clear();
        extraShield = 0;

        field.ResetShield();
    }
示例#5
0
 private void buttonNewGame_Click(object sender, RoutedEventArgs e)
 {
     groupBox.IsEnabled            = true;
     groupBox1.IsEnabled           = true;
     Group1.IsEnabled              = true;
     buttonStartGame.IsEnabled     = false;
     buttonNewGame.IsEnabled       = false;
     buttonClear.IsEnabled         = true;
     buttonAutoPlacement.IsEnabled = true;
     MyField.ClearField();
     EnemyField.ClearField();
     EnemyField.ClickOnBox -= EnemyField_ClickBox;
     MyField.ClickOnBox    += MyField_ClickOnBox;
 }
示例#6
0
 private void buttonStartGame_Click(object sender, RoutedEventArgs e)
 {
     Group1.IsEnabled              = false;
     groupBox.IsEnabled            = false;
     groupBox1.IsEnabled           = false;
     buttonClear.IsEnabled         = false;
     buttonAutoPlacement.IsEnabled = false;
     buttonNewGame.IsEnabled       = true;
     EnemyField.ClickOnBox        += EnemyField_ClickBox;
     buttonStartGame.IsEnabled     = false;
     EnemyField.AutoPlacementShips(new Ships(beginShips));
     enemy = new EnemyAI(lvlEnemy, MyField);
     BattleShipDB.IncCountGame();
 }
示例#7
0
 /*
  * 敵にあたってシーン遷移
  * プレイヤーと敵の情報を保存
  */
 public void Battle(GameObject enemy)
 {
     Debug.Log("戦闘画面に移行します。");
     for (int i = 0; i < enemyList.Count; i++)
     {
         EnemyField e = enemy.GetComponent <EnemyField>();
         if (enemyList[i] == e)
         {
             enemyList.RemoveAt(i);
             Debug.Log("残りのダンジョン内にいる敵は、 " + enemyList.Count + " 体です。");
         }
     }
     GlobalDataManager.GetGlobalData().SavePlayerData(playerOwner);
     GlobalDataManager.GetGlobalData().SaveEnemyDataList(enemyList);
     gameManager.Battle();
 }
示例#8
0
        public PlayPage(OnlineGame onlineGame)
        {
            WindowConfig.PlayPageCon = this;
            WindowConfig.OnlineGame  = onlineGame;
            WindowConfig.IsLoaded    = onlineGame.GameConfig.GameStatus == GameStatus.Loaded;
            OnlineGame             = onlineGame;
            WindowConfig.GameState = WindowConfig.State.Online;
            InitializeComponent();
            WindowConfig.GetCurrentAudioImg(AudioImg);
            MyField.PlaceHitted();
            EnemyField.PlaceHitted();
            PauseItem.IsEnabled    = OnlineGame.PlayerRole == PlayerRole.Server;
            SaveGameItem.IsEnabled = OnlineGame.PlayerRole == PlayerRole.Server;
            WindowConfig.SetStartColor();
            IsPaused = false;

            //ImageBehavior.SetAnimatedSource(TimerImage, new BitmapImage(new Uri("/Resources/timer.gif", UriKind.Relative)) { CreateOptions = BitmapCreateOptions.IgnoreImageCache });
            //ImageBehavior.SetAnimateInDesignMode(TimerImage, true);
            GameSpeed gs = WindowConfig.GameState == WindowConfig.State.Online ? OnlineGame.GameConfig.GameSpeed : Game.GameConfig.GameSpeed;

            switch (gs)
            {
            case GameSpeed.Fast:
                timer.Interval = new TimeSpan(0, 0, 0, 1, 250);
                break;

            case GameSpeed.Medium:
                timer.Interval = new TimeSpan(0, 0, 0, 2, 500);
                break;

            case GameSpeed.Slow:
                timer.Interval = new TimeSpan(0, 0, 0, 5);
                break;

            case GameSpeed.Turtle:
                timer.Interval = new TimeSpan(0, 0, 0, 12, 500);
                break;
            }

            //  timer.Interval = new TimeSpan(0, 0, 1);
            timer.Tick += Tick;
            // timer.Start();

            InitTimer();
            Timer.Start();
            timer.Start();
        }
示例#9
0
文件: Game.cs 项目: Duxaman/SeaBattle
 public bool MakeMove(Point cell)
 {
     //do not change current move state until answer from enemy received
     if (CurrentMove)
     {
         //check if one can fire that cell
         if (EnemyField.getCell(cell.X, cell.Y).State == CellState.Free)
         {
             GameData Data = new GameData(GameMessage.Attack);
             Data.AttackingCell = cell;
             Data.GameId        = GameId;
             SendMessage(this, Data);
             return(true);
         }
     }
     return(false);
 }
示例#10
0
    // 経路の作成
    private void CreateRoute()
    {
        Debug.Log("ルートの生成を開始します。");
        int loop        = 0; // 無限ループ回避用 とりあえず 1000
        int color_index = 0;

        while (areaRouteList.Count < DUNGEON_SIZE * DUNGEON_SIZE)
        {
            int area_index = areaRouteList[areaRouteList.Count - 1] - 1;

            // 次のアリア方向の取得
            List <int> dir_list   = SqueezeDir(areaList[area_index].GetNextToAreaList());
            int        next_index = 0;

            // 行き止まり処理
            if (dir_list.Count == 0)
            {
                areaList[area_index].RoomCenter();
                for (int i = areaRouteList.Count - 1; i >= 0; i--)
                {
                    int        r_area_index = areaRouteList[i] - 1;
                    List <int> r_dir_list   = SqueezeDir(areaList[r_area_index].GetNextToAreaList());
                    if (r_dir_list.Count != 0)
                    {
                        int rand = Random.Range(0, r_dir_list.Count);
                        next_index = r_dir_list[rand];
                        areaList[r_area_index].CreateDoor(next_index);
                        areaList[next_index - 1].CreateDoor(r_area_index + 1);
                        areaRouteList.Add(next_index);
                        color_index++;
                        break;
                    }
                }
            }
            else
            {
                int rand = Random.Range(0, dir_list.Count);
                next_index = dir_list[rand];
                areaList[area_index].CreateDoor(next_index);
                areaList[next_index - 1].CreateDoor(area_index + 1);

                areaRouteList.Add(next_index);
                color_index++;
                if (areaRouteList.Count >= DUNGEON_SIZE * DUNGEON_SIZE)
                {
                    EnemyField enemy = Instantiate(enemyObj, areaList[area_index].GetRoomInRandomPosition(), Quaternion.Euler(0, 0, 0)) as EnemyField;
                    enemy.Manager = this;
                    enemy.Target  = playerOwner.gameObject;
                    enemyList.Add(enemy);
                    areaList[next_index - 1].RoomCenter();
                }
                else if (areaRouteList[0] - 1 == area_index)
                {
                    playerOwner.transform.position = areaList[areaRouteList[0] - 1].GetRoomInRandomPosition();
                }
                else
                {
                    EnemyField enemy = Instantiate(enemyObj, areaList[area_index].GetRoomInRandomPosition(), Quaternion.Euler(0, 0, 0)) as EnemyField;
                    enemy.Manager = this;
                    enemy.Target  = playerOwner.gameObject;
                    enemyList.Add(enemy);
                }
            }
            if (loop++ >= 1000)
            {
                break;
            }
        }
        Debug.Log("ルートの生成を終了しました。");
    }
示例#11
0
 public void SetEnemyField(EnemyField _enemyField)
 {
     enemyField = _enemyField;
 }
示例#12
0
文件: Game.cs 项目: Duxaman/SeaBattle
        public void ReceiveMsg(object sender, GameData Data)
        {
            //parse message

            /*
             * first check if id is the same, if id is not set set it
             * dann if its attack request return message about succesfuly
             *
             */
            if (Data.GameId == GameId)
            {
                bool labelupdaterequired = false;
                switch (Data.Type)
                {
                case GameMessage.Attack:
                {
                    GameData respond = new GameData(GameMessage.AttackRespond);

                    respond.GameId = GameId;
                    //check and send respond back
                    Field.Cell CheckingCell = MyField.getCell(Data.AttackingCell.X, Data.AttackingCell.Y);
                    if (CheckingCell.State == CellState.Occupied)
                    {
                        MyDeckCounter[CheckingCell.Shipid].DeckRemains -= 1;
                        if (MyDeckCounter[CheckingCell.Shipid].DeckRemains == 0)
                        {
                            switch (MyDeckCounter[CheckingCell.Shipid].Type)
                            {
                            case ShipType.FourDeck: MyCounters[0]--; break;

                            case ShipType.ThreeDeck: MyCounters[1]--; break;

                            case ShipType.TwoDeck: MyCounters[2]--; break;

                            case ShipType.OneDeck: MyCounters[3]--; break;
                            }
                            MyDeckCounter.Remove(CheckingCell.Shipid);
                            labelupdaterequired = true;
                        }
                        MyField.setCellState(Data.AttackingCell.X, Data.AttackingCell.Y, CellState.Hit);
                        respond.shiptype      = CheckingCell.Type;
                        respond.AttackResult  = true;
                        respond.shipId        = CheckingCell.Shipid;
                        respond.AttackingCell = Data.AttackingCell;
                        SendMessage(this, respond);
                        OnDataUpdate(this, new DataUpdateEventArguments(true, Data.AttackingCell, labelupdaterequired));
                        if (labelupdaterequired)
                        {
                            if (MyDeckCounter.Count == 0)
                            {
                                OnGameFinished(this, false);
                            }
                        }
                    }
                    else if (CheckingCell.State == CellState.Free)
                    {
                        MyField.setCellState(Data.AttackingCell.X, Data.AttackingCell.Y, CellState.Missed);
                        respond.AttackResult  = false;
                        respond.AttackingCell = Data.AttackingCell;
                        SendMessage(this, respond);
                        OnDataUpdate(this, new DataUpdateEventArguments(true, Data.AttackingCell, false));
                        CurrentMove = true;
                    }


                    //if the there is no ships, invoke endgame
                    ChangeMove(this, new EventArgs());
                }
                break;

                case GameMessage.AttackRespond:
                {
                    //add data to local list, invoke gamefinish if there is no ships left
                    //invoke update data, change mode
                    if (Data.GameId == GameId)
                    {
                        if (Data.AttackResult)
                        {
                            if (EnemyDeckCounter.ContainsKey(Data.shipId))
                            {
                                CurrentMove = true;
                                EnemyDeckCounter[Data.shipId].DeckRemains--;
                                if (EnemyDeckCounter[Data.shipId].DeckRemains == 0)
                                {
                                    labelupdaterequired = true;
                                    EnemyCounters[(byte)EnemyDeckCounter[Data.shipId].Type]--;
                                    EnemyDeckCounter.Remove(Data.shipId);
                                }
                                EnemyField.setCellState(Data.AttackingCell.X, Data.AttackingCell.Y, CellState.Hit);
                                OnDataUpdate(this, new DataUpdateEventArguments(false, Data.AttackingCell, labelupdaterequired));
                                //if all enemycounters == 0  dann we win
                                if (EnemyCounters[0] == 0 && EnemyCounters[1] == 0 && EnemyCounters[2] == 0 && EnemyCounters[3] == 0)
                                {
                                    OnGameFinished(this, true);
                                }
                            }
                            else
                            {
                                EnemyDeckCounter.Add(Data.shipId, new ship(Data.shiptype));
                                ReceiveMsg(this, Data);
                            }
                        }
                        else
                        {
                            CurrentMove = false;
                            EnemyField.setCellState(Data.AttackingCell.X, Data.AttackingCell.Y, CellState.Missed);
                            OnDataUpdate(this, new DataUpdateEventArguments(false, Data.AttackingCell, labelupdaterequired));
                        }
                    }
                    ChangeMove(this, new EventArgs());
                }
                break;

                case GameMessage.EndGame:
                {
                    //finish game with win msg
                    //invoke game finished
                    OnGameFinished(this, true);
                }
                break;
                }
            }
            else
            {
                if (GameId == "00000-1")
                {
                    GameId = Data.GameId;
                    ReceiveMsg(sender, Data);
                }
            }
        }
示例#13
0
    // Use this for initialization
    void Start()
    {
        gameplay = this;

        _MainCamera = (Camera)gameObject.GetComponent("Camera");

        _SelectionListWindow = new SelectionListWindow(Screen.width / 2, Screen.height / 2 + 100);

        _AbilityManagerList = new SelectionListGenericWindow(Screen.width / 2, Screen.height / 2 + 100);

        _SelectionCardNameWindow = new SelectionCardNameWindow(Screen.width / 2 - 50, Screen.height / 2);
        _SelectionCardNameWindow.CreateCardList();
        _SelectionCardNameWindow.SetGame(this);

        _DecisionWindow = new DecisionWindow(Screen.width / 2, Screen.height / 2 + 100);
        _DecisionWindow.SetGame(this);

        _NotificationWindow = new NotificacionWindow(Screen.width / 2, Screen.height / 2 + 100);
        _NotificationWindow.SetGame(this);

        FromHandToBindList = new List<Card>();

        AttackedList = new List<Card>();

        UnitsCalled = new List<Card>();

        EnemySoulBlastQueue = new List<Card>();

        _PopupNumber = new PopupNumber();

        _MouseHelper = new MouseHelper(this);
        GameChat = new Chat();

        opponent = PlayerVariables.opponent;

        playerHand = new PlayerHand();
        enemyHand = new EnemyHand();

        field = new Field(this);
        enemyField = new EnemyField(this);
        guardZone = new GuardZone();
        guardZone.SetField(field);
        guardZone.SetEnemyField(enemyField);
        guardZone.SetGame(this);

        fieldInfo = new FieldInformation();
        EnemyFieldInfo = new EnemyFieldInformation();

        Data = new CardDataBase();
        List<CardInformation> tmpList = Data.GetAllCards();
        for(int i = 0; i < tmpList.Count; i++)
        {
            _SelectionCardNameWindow.AddNewNameToTheList(tmpList[i]);
        }

        //camera = (CameraPosition)GameObject.FindGameObjectWithTag("MainCamera").GetComponent("CameraPosition");
        //camera.SetLocation(CameraLocation.Hand);

        LoadPlayerDeck();
        LoadEnemyDeck();

        gamePhase = GamePhase.CHOOSE_VANGUARD;

        bDrawing = true;
        bIsCardSelectedFromHand = false;
        bPlayerTurn = false;

        bDriveAnimation = false;
        bChooseTriggerEffects = false;
        DriveCard = null;

        //Texture showed above a card when this is selected for an action (An attack, for instance)
        CardSelector = GameObject.FindGameObjectWithTag("CardSelector");
        _CardMenuHelper = (CardHelpMenu)GameObject.FindGameObjectWithTag("CardMenuHelper").GetComponent("CardHelpMenu");
        _GameHelper = (GameHelper)GameObject.FindGameObjectWithTag("GameHelper").GetComponent("GameHelper");

        bPlayerTurn = PlayerVariables.bFirstTurn;

        //ActivePopUpQuestion(playerDeck.DrawCard());
        _CardMenu = new CardMenu(this);

        _AbilityManager = new AbilityManager(this);
        _AbilityManagerExt = new AbilityManagerExt();

        _GameHelper.SetChat(GameChat);
        _GameHelper.SetGame(this);

        EnemyTurnStackedCards = new List<Card>();

        dummyUnitObject = new UnitObject();
        dummyUnitObject.SetGame(this);

        stateDynamicText = new DynamicText();
    }