Example #1
0
        private void DecideUnitRandom(bool notice = false, bool spaceOnly = false)
        {
            if (!VersusDraftList.VersusDraftTurnOwn)
            {
                return;
            }
            int num = this.SelectableUnitCount;

            if (spaceOnly)
            {
                num = this.SelectableUnitCount - VersusDraftUnit.CurrentSelectCursors.FindAll((Predicate <VersusDraftUnit>)(u => UnityEngine.Object.op_Inequality((UnityEngine.Object)u, (UnityEngine.Object)null))).Count;
            }
            for (int index = 0; index < num; ++index)
            {
                VersusDraftUnit randomUnit = this.GetRandomUnit();
                if (UnityEngine.Object.op_Equality((UnityEngine.Object)randomUnit, (UnityEngine.Object)null))
                {
                    return;
                }
                randomUnit.SelectUnit(true);
            }
            if (!notice)
            {
                return;
            }
            this.SelectUnit();
        }
Example #2
0
 private void Initialize()
 {
     this.mSingleMode          = false;
     this.mVersusDraftUnitList = new List <VersusDraftUnit>();
     for (int index1 = 0; index1 < VersusDraftList.VersusDraftUnitList.Count && (this.mDraftUnitTransforms != null && this.mDraftUnitTransforms.Length > 0); ++index1)
     {
         Json_Unit jsonUnit = VersusDraftList.VersusDraftUnitList[index1].GetJson_Unit();
         if (jsonUnit != null)
         {
             UnitData unit = new UnitData();
             unit.Deserialize(jsonUnit);
             if (unit != null)
             {
                 VersusDraftUnit versusDraftUnit = (VersusDraftUnit)UnityEngine.Object.Instantiate <VersusDraftUnit>((M0)this.mDraftUnitItem);
                 this.mVersusDraftUnitList.Add(versusDraftUnit);
                 Transform draftUnitTransform = this.mDraftUnitTransforms[0];
                 int       index2             = 0;
                 for (int index3 = 0; index3 < this.DRAFT_UNIT_LIST_COLS.Length; ++index3)
                 {
                     if (index1 < this.DRAFT_UNIT_LIST_COLS[index3])
                     {
                         index2 = index3;
                         break;
                     }
                 }
                 if (this.mDraftUnitTransforms.Length > index2)
                 {
                     draftUnitTransform = this.mDraftUnitTransforms[index2];
                 }
                 versusDraftUnit.SetUp(unit, draftUnitTransform, VersusDraftList.VersusDraftUnitList[index1].IsHidden);
             }
         }
     }
     this.mVersusDraftSelectedUnit = new List <VersusDraftSelectedUnit>();
     for (int index = 0; index < 6 && !UnityEngine.Object.op_Equality((UnityEngine.Object) this.mSelectedUnitTransform, (UnityEngine.Object)null); ++index)
     {
         VersusDraftSelectedUnit draftSelectedUnit = (VersusDraftSelectedUnit)UnityEngine.Object.Instantiate <VersusDraftSelectedUnit>((M0)this.mSelectedUnitItem);
         this.mVersusDraftSelectedUnit.Add(draftSelectedUnit);
         ((Component)draftSelectedUnit).get_transform().SetParent(this.mSelectedUnitTransform, false);
         ((Component)draftSelectedUnit).get_gameObject().SetActive(true);
         draftSelectedUnit.Initialize();
     }
     this.mRandomSelecting = false;
     VersusDraftList.VersusDraftUnitDataListPlayer = new List <UnitData>();
     VersusDraftList.VersusDraftUnitDataListEnemy  = new List <UnitData>();
     FlowNode_GameObject.ActivateOutputLinks((Component)this, 101);
 }
Example #3
0
        private bool ChangeTurn(bool isPlayer = true)
        {
            ++this.mTurn;
            if (this.SELECTABLE_UNIT_COUNT_OF_TURN.Length <= this.mTurn)
            {
                this.StartCoroutine(this.DownloadUnitImage());
                return(true);
            }
            VersusDraftList.VersusDraftTurnOwn = isPlayer;
            this.mTimerGO.SetActive(isPlayer);
            ((Component)this.mPlayerText).get_gameObject().SetActive(isPlayer);
            ((Component)this.mEnemyText).get_gameObject().SetActive(!isPlayer);
            VersusDraftUnit.ResetSelectUnit();
            string str1;
            string str2;

            if (isPlayer)
            {
                this.mPlayerTimer = 0.0f;
                FlowNode_GameObject.ActivateOutputLinks((Component)this, 110);
                str1 = LocalizedText.Get("sys.DRAFT_TURN_PLAYER");
                str2 = (this.mSelectingUnitIndex + 1).ToString();
                for (int index = 1; index < this.SelectableUnitCount; ++index)
                {
                    str2 = str2 + "," + (this.mSelectingUnitIndex + 1 + index).ToString();
                }
                this.mTimerText.set_text(((int)this.mDraftSec).ToString());
                this.mPlayerText.set_text(str1 + string.Format(LocalizedText.Get("sys.DRAFT_UNIT_SELECT_MESSAGE_PLAYER"), (object)str2));
            }
            else
            {
                FlowNode_GameObject.ActivateOutputLinks((Component)this, 111);
                str1 = LocalizedText.Get("sys.DRAFT_TURN_ENEMY");
                str2 = (this.mEnemyUnitIndex + 1).ToString();
                for (int index = 1; index < this.SelectableUnitCount; ++index)
                {
                    str2 = str2 + "," + (this.mEnemyUnitIndex + 1 + index).ToString();
                }
                this.mEnemyText.set_text(str1 + string.Format(LocalizedText.Get("sys.DRAFT_UNIT_SELECT_MESSAGE_ENEMY"), (object)str2));
            }
            this.mTurnChangeUserText.set_text(str1);
            this.mTurnChangeMessage.set_text(string.Format(LocalizedText.Get("sys.DRAFT_CHANGE_TURN_MESSAGE"), (object)str2));
            return(false);
        }
Example #4
0
 private void DecideUnit()
 {
     if (this.mRandomSelecting || !VersusDraftList.VersusDraftTurnOwn || this.mSelectingUnitIndex >= 6)
     {
         return;
     }
     VersusDraftList.VersusDraftMessageData mess = new VersusDraftList.VersusDraftMessageData();
     mess.h = 2;
     if (UnityEngine.Object.op_Inequality((UnityEngine.Object)VersusDraftUnit.CurrentSelectCursors[0], (UnityEngine.Object)null))
     {
         VersusDraftUnit currentSelectCursor = VersusDraftUnit.CurrentSelectCursors[0];
         int             num = this.mVersusDraftUnitList.IndexOf(VersusDraftUnit.CurrentSelectCursors[0]);
         currentSelectCursor.DecideUnit(true);
         mess.uidx0 = num;
         this.mVersusDraftSelectedUnit[this.mSelectingUnitIndex].Select(currentSelectCursor.UnitData);
         ++this.mSelectingUnitIndex;
     }
     if (UnityEngine.Object.op_Inequality((UnityEngine.Object)VersusDraftUnit.CurrentSelectCursors[1], (UnityEngine.Object)null))
     {
         VersusDraftUnit currentSelectCursor = VersusDraftUnit.CurrentSelectCursors[1];
         int             num = this.mVersusDraftUnitList.IndexOf(VersusDraftUnit.CurrentSelectCursors[1]);
         currentSelectCursor.DecideUnit(true);
         mess.uidx1 = num;
         this.mVersusDraftSelectedUnit[this.mSelectingUnitIndex].Select(currentSelectCursor.UnitData);
         ++this.mSelectingUnitIndex;
     }
     if (UnityEngine.Object.op_Inequality((UnityEngine.Object)VersusDraftUnit.CurrentSelectCursors[2], (UnityEngine.Object)null))
     {
         VersusDraftUnit currentSelectCursor = VersusDraftUnit.CurrentSelectCursors[2];
         int             num = this.mVersusDraftUnitList.IndexOf(VersusDraftUnit.CurrentSelectCursors[2]);
         currentSelectCursor.DecideUnit(true);
         mess.uidx2 = num;
         this.mVersusDraftSelectedUnit[this.mSelectingUnitIndex].Select(currentSelectCursor.UnitData);
         ++this.mSelectingUnitIndex;
     }
     this.SendRoomMessage(mess, false);
     this.FinishTurn();
 }
Example #5
0
        private void UpdateSingleMode()
        {
            if (!this.mSingleMode)
            {
                List <MyPhoton.MyPlayer> roomPlayerList = PunMonoSingleton <MyPhoton> .Instance.GetRoomPlayerList();

                if (roomPlayerList != null && roomPlayerList.Count >= 2)
                {
                    return;
                }
                this.mSingleMode = true;
            }
            else
            {
                if (VersusDraftList.VersusDraftTurnOwn)
                {
                    return;
                }
                this.mEnemyTimer += Time.get_unscaledDeltaTime();
                if ((double)this.mEnemyTimer < 5.0)
                {
                    return;
                }
                this.mEnemyTimer = 0.0f;
                for (int index = 0; index < this.SelectableUnitCount; ++index)
                {
                    VersusDraftUnit randomUnit = this.GetRandomUnit();
                    if (UnityEngine.Object.op_Equality((UnityEngine.Object)randomUnit, (UnityEngine.Object)null))
                    {
                        return;
                    }
                    randomUnit.SelectUnit(false);
                    randomUnit.DecideUnit(false);
                    ++this.mEnemyUnitIndex;
                }
                this.ChangeTurn(true);
            }
        }
Example #6
0
        private void UpdatePhotonMessage()
        {
            MyPhoton instance = PunMonoSingleton <MyPhoton> .Instance;

            if (UnityEngine.Object.op_Equality((UnityEngine.Object)instance, (UnityEngine.Object)null))
            {
                return;
            }
            List <MyPhoton.MyEvent> events = instance.GetEvents();

            if (events == null)
            {
                return;
            }
            while (events.Count > 0)
            {
                MyPhoton.MyEvent myEvent = events[0];
                events.RemoveAt(0);
                if (myEvent.code == MyPhoton.SEND_TYPE.Normal && myEvent.binary != null)
                {
                    VersusDraftList.VersusDraftMessageData buffer = (VersusDraftList.VersusDraftMessageData)null;
                    if (GameUtility.Binary2Object <VersusDraftList.VersusDraftMessageData>(out buffer, myEvent.binary) && buffer != null)
                    {
                        switch (buffer.h)
                        {
                        case 1:
                            VersusDraftUnit.ResetSelectUnit();
                            if (buffer.uidx0 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx0)
                            {
                                this.mVersusDraftUnitList[buffer.uidx0].SelectUnit(false);
                            }
                            if (buffer.uidx1 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx1)
                            {
                                this.mVersusDraftUnitList[buffer.uidx1].SelectUnit(false);
                            }
                            if (buffer.uidx2 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx2)
                            {
                                this.mVersusDraftUnitList[buffer.uidx2].SelectUnit(false);
                                continue;
                            }
                            continue;

                        case 2:
                            if (buffer.uidx0 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx0)
                            {
                                this.mVersusDraftUnitList[buffer.uidx0].DecideUnit(false);
                                ++this.mEnemyUnitIndex;
                            }
                            if (buffer.uidx1 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx1)
                            {
                                this.mVersusDraftUnitList[buffer.uidx1].DecideUnit(false);
                                ++this.mEnemyUnitIndex;
                            }
                            if (buffer.uidx2 >= 0 && this.mVersusDraftUnitList.Count > buffer.uidx2)
                            {
                                this.mVersusDraftUnitList[buffer.uidx2].DecideUnit(false);
                                ++this.mEnemyUnitIndex;
                                continue;
                            }
                            continue;

                        case 3:
                            if (!this.ChangeTurn(true))
                            {
                                for (int index = 0; index < this.SELECTABLE_UNIT_COUNT_OF_TURN[this.mTurn]; ++index)
                                {
                                    this.mVersusDraftSelectedUnit[this.mSelectingUnitIndex + index].Selecting();
                                }
                                continue;
                            }
                            continue;

                        default:
                            continue;
                        }
                    }
                }
            }
        }