Exemple #1
0
    // Use this for initialization
    void Start()
    {
        // インスタンスの初期化
        phaseManager = this;

        // エリア描画用関連の読み込み
        attackArea = new GameObject("AttackArea");
        activeArea = new GameObject("activeArea");

        attackArea.transform.parent = transform;
        activeArea.transform.parent = transform;

        // プレイヤーターンから始める
        TurnChange(Enums.ARMY.ALLY);

        attackBtn   = GameObject.Find("CanvasUI/ActiveUI/AttackButton").GetComponent <Button>();
        recoveryBtn = GameObject.Find("CanvasUI/ActiveUI/RecoveryButton").GetComponent <Button>();
        waitingBtn  = GameObject.Find("CanvasUI/ActiveUI/EndButton").GetComponent <Button>();
        turnEndBtn  = GameObject.Find("CanvasUI/ActiveUI/TurnEndButton").GetComponent <Button>();

        battleStandbyUI.SetActive(false);

        //各ボタンの無効化
        attackBtn.interactable   = false;
        recoveryBtn.interactable = false;
        waitingBtn.interactable  = false;

        // カーソル更新時に呼び出す処理の登録
        CursorController.AddCallBack((Vector3 newPos) => { cursorPos = newPos; });


        // シーンをロード
        //SceneManager.LoadScene("conversation", LoadSceneMode.Additive);
    }
Exemple #2
0
    public void Initialize(PhaseManager phaseManager, TurnManager turnManager)
    {
        _phaseManager = phaseManager;
        _turnManager  = turnManager;

        GameObject canvas = GameObject.FindGameObjectWithTag("Canvas");

        for (int i = 0; i < _teamAmount; ++i)
        {
            bool isAi = true;
            if (i == 0)
            {
                isAi = false;
            }
            Team newTeam = GameObject.Instantiate(_teamPrefab);
            newTeam.Initialize(i, isAi);

            newTeam.OnCardActivate           += DoCardActivate;
            newTeam.OnTeamPlayerStaminaEmpty += DoTeamPlayerStaminaEmpty;
            newTeam.OnTeamPlayerHealthEmpty  += DoTeamPlayerHealthEmpty;

            newTeam.transform.SetParent(canvas.transform);
            newTeam.SetPosition(new Vector2(
                                    Mathf.Cos(i * (2.0f * Mathf.PI / _teamAmount) - Mathf.PI / 2.0f) * _teamOffset,
                                    Mathf.Sin(i * (2.0f * Mathf.PI / _teamAmount) - Mathf.PI / 2.0f) * _teamOffset));
            newTeam.SetRotation(i * (360.0f / _teamAmount));
            _teams.Add(newTeam);
        }
    }
    public List <MonsterRisk> IncreaseThreat()
    {
        //Debug.Log("밤 인크리스 뜨리트");
        List <MonsterRisk> increaseAtNight = new List <MonsterRisk>();

        //밤에 사냥감 들의 수를 올림/
        //결국 원하는 건. 밤에 정산 할때 몹 전체 위협도 그래프가
        //줄어들었다가
        //다시 올라가는 효과를 원해서 이 짓을 하고 있다.
        for (int i = 0; i < (int)E_Monster.MAX; i++)                           //출몰이랑 섞어서.
        {
            if (false == PhaseManager.GetInstance().IsMobShowUP((E_Monster)i)) //출몰 안한 몹이면 몹 젠에서 패쓰
            {
                increaseAtNight.Add(new MonsterRisk((E_Monster)i));
                continue;
            }
            int rand        = Random.Range(7, 12);
            int increaseNum = maxThreatDic[(E_Monster)i] / rand;

            if (monsterRiskList[i].nowNum + increaseNum > maxThreatDic[(E_Monster)i])
            {
                increaseNum = maxThreatDic[(E_Monster)i] - monsterRiskList[i].nowNum;
            }

            increaseAtNight.Add(new MonsterRisk((E_Monster)i, increaseNum));
            Debug.Log("위험도 추가" + ((E_Monster)i).ToString() + "몇 " + increaseNum);
        }
        IADMRList(increaseAtNight, true);
        return(increaseAtNight);
    }
Exemple #4
0
    /// <summary>
    /// Executes the next phase, ends the turn if the phase index is at 3
    /// </summary>
    /// <returns></returns>
    public bool executeNextPhase()
    {
        DebugControl.log("turn", "--PHASE " + phaseIndex);

        // if the phase index is 3, then the fourth phase has been completed
        if (phaseIndex >= 3)
        {
            if (PhotonNetwork.IsMasterClient)
            {
                foreach (Team t in gameManager.teams)
                {
                    if (t.TeamType == Team.Type.player)
                    {
                        Debug.Log(t.TeamFaction + " is being set unready.");
                        PhotonView.Get(this).RPC("setUnready", RpcTarget.All, (int)t.TeamFaction);
                    }
                }
            }


            endTurn();

            return(false);
        }
        else
        {
            phaseIndex++;
            PhaseManager.updateText(GameLogic.phaseIndex);
            executePhase(phaseIndex);
            return(true);
        }
    }
    /// <summary>
    /// Checks if this target resolution still needs to be resolved
    /// Returns true only if the attacking ship is still alive and has more than 1 targets
    /// </summary>
    /// <returns></returns>
    public bool needsResolving()
    {
        if (attacker == null)
        {
            return(false);
        }
        int  validTargets = 0;
        Ship target       = null;

        foreach (Ship s in targets)
        {
            if (s != null)
            {
                target = s;
                validTargets++;
            }
        }
        if (validTargets == 0)
        {
            return(false);
        }
        if (validTargets == 1)
        {
            PhaseManager.addCatapultAnimation(attacker, target);
            return(false);
        }
        return(true);
    }
    /// <summary>
    /// Plays the rotation animation. Instantiates a sprite indicating rotation.
    /// </summary>
    /// <returns></returns>
    public override IEnumerator playAnimation()
    {
        if (complete)
        {
            yield break;
        }

        yield return(PhaseManager.SyncFocus(focusPoint));

        Vector2 position = ship.transform.position;

        if (PhotonNetwork.IsConnected && PhotonNetwork.IsMasterClient)
        {
            PhotonView.Get(GameManager.main).RPC("CreateRotationArrow", RpcTarget.All, (int)ship.team.TeamFaction, focusPoint.x, focusPoint.y, ship.transform.rotation.eulerAngles.z, portTurn);
        }
        //PhotonView.Get(GameManager.main).RPC("CreateRotationArrow",RpcTarget.Others,(int)ship.team.TeamFaction,focusPoint.x,position.y,ship.transform.rotation.eulerAngles.z,portTurn);

        yield return(new WaitForSeconds(SpeedManager.ActionDelay));

        if (!complete)
        {
            startTime = Time.time;

            while (Time.time - startTime < SpeedManager.ActionSpeed)
            {
                ship.transform.rotation = Quaternion.Lerp(startRotation, endRotation, (Time.time - startTime) / SpeedManager.ActionSpeed);
                yield return(null);
            }
            complete = true;
            ship.transform.rotation = endRotation;
        }
    }
    Quest MakeRandomOrderQuest()//랜던으로 퀘스트 만들어주기.
    {
        Quest quest = new Quest();

        //모킹
        quest.ClientName = charaName;
        List <E_Monster> showedMob = new List <E_Monster>();

        for (int i = 0; i < (int)E_Monster.MAX; i++)
        {
            if (PhaseManager.GetInstance().IsMobShowUP((E_Monster)i))
            {
                showedMob.Add((E_Monster)i);
            }
        }
        List <E_Evidence> opendEvi = PhaseManager.GetInstance().GetOpendEviDataList();

        int kinds = Random.Range(1, Constant.clientMaxOrderNum + 1);    //qpm종류로 몇개를 할 건지.

        for (int i = 0; i < kinds; i++)
        {
            E_Monster  mob      = showedMob[Random.Range(0, showedMob.Count)];
            E_Evidence evidence = opendEvi[Random.Range(0, opendEvi.Count)];
            int        number   = GetNumOfQPM();

            quest.AddQuestMob(new QuestPerMob(mob, evidence, number));
        }

        return(quest);
    }
    void CheckMonsterShowUp()
    {
        mobShowUpScreen.SetActive(false);
        int    daysAfter  = InGameTimeManager.GetInstance().GetDaysAfterGameStart();
        string noticeBase = UIGeneralTextsManager.GetUIGeneralText("mobshowup", "notice");

        mobShowUpExitBtn.onClick.AddListener(() => { mobShowUpScreen.SetActive(false); });

        for (int i = (int)E_Monster.GARGOYLE; i < (int)E_Monster.MAX; i++)    //가고일 부터 체크 시작.
        {
            E_Monster mob       = (E_Monster)i;
            int       showUpDay = MobEviInfoManager.GetInstance().GetMonsterShowUpDay(mob);
            string    mobname   = MobEviInfoManager.GetInstance().GetMobName(mob);
            string    notice    = noticeBase.Replace("[0]", mobname);

            if (daysAfter == showUpDay)
            {
                AudioThing.GetInstance().PlaySFX(AudioThing.E_SFX.GROWL);
                PhaseManager.GetInstance().MonsterShowUp(mob);  //몬스터 출현하도록 처리

                showUpMobStampedImage.sprite = SpriteManager.GetInstance().GetMobStampedSprite(mob);
                mobShowUpText.text           = notice;
                mobShowUpScreen.SetActive(true);
                PhaseManager.GetInstance().LogDebug();
                return;
            }
        }
    }
Exemple #9
0
 public void Initialize(int teamAmount, TeamManager teamManager, PhaseManager phaseManager)
 {
     _teamManager  = teamManager;
     _phaseManager = phaseManager;
     _teamAmount   = teamAmount;
     _isAttacking  = true;
 }
Exemple #10
0
 /// <summary>
 /// Adds a catapult animation targetting the given ship
 /// </summary>
 /// <param name="target"></param>
 public void catapult(Ship target)
 {
     if (target != null)
     {
         PhaseManager.addCatapultAnimation(this, target);
     }
 }
Exemple #11
0
    protected void Init()
    {
        UnToggle();
        PhaseManager phase = PhaseManager.GetInstance();

        _currentPlayer = phase.CurrentPlayer;
    }
Exemple #12
0
        private IEnumerator BeginGameEffect()
        {
            if (RelicCollection == null)
            {
                RelicCollection = new RelicCollection();
            }
            else
            {
                RelicCollection.Reset();
            }

            if (StatisticManager == null)
            {
                StatisticManager = new StatisticManager();
            }
            else
            {
                StatisticManager.Reset();
            }

            // Fire a game begun event.
            OnGameBegun(EventArgs.Empty);

            yield return(Coroutines.Pause(TimingHelper.GetFrameCount(2.5f)));

            // Kick off the game with a coalsced phase. This should always be the Calm phase and we do want the player to be notified of this.
            PhaseManager.CoalescePlane();

            // Add a coroutine to handle updating remaining game time.
            CoroutineManager.Add(UpdateRemainingGameTimeKey, UpdateGameTimer());
        }
Exemple #13
0
    public void newPhaseCallback()
    {
        PhaseManager phaseMan  = gameObject.GetComponent <PhaseManager> ();
        TypeFase     typePhase = phaseMan.getCurrentPhase();

        Debug.Log("New Phase: " + typePhase.ToString());
        //TimeManager timeMan = gameObject.GetComponent<TimeManager> ();
        WorldTerrain wt = WorldTerrain.GetInstance();

        switch (typePhase)
        {
        case TypeFase.SOWING:
            if (Tutorial_Plantell.init == false && !wt.areAllChunksDisabled())
            {
                _tutMan.startTuto(new Tutorial_Plantell());
            }
            break;

        case TypeFase.HARVEST:
            if (Tutorial_Buildings.init == false && !wt.areAllChunksDisabled())
            {
                _tutMan.startTuto(new Tutorial_Buildings());
            }
            break;
        }
    }
Exemple #14
0
        /// <summary>
        /// Collects this item.
        /// </summary>
        /// <param name="player">The player.</param>
        public override void Collect(IPlayer player)
        {
            base.Collect(player);

            // Force a coalesce of dimensional planes.
            PhaseManager.CoalescePlane();
        }
Exemple #15
0
        public Game()
        {
            GameBuilder builder = new GameBuilder();

            Cg = builder.CustomGameBuilder();

            Phases = builder.PhaseManagerBuilder();
            _loop  = builder.LoopBuilder(Phases);

            Chat = builder.ChatBuilder(Cg.Chat);

            //ISlotContentHistory slotContentHistory = builder.SlotContentHistoryBuilder();


            BotsModifiedFlag modifiedFlag = new BotsModifiedFlag();

            Slots = builder.SlotBuilder(Cg.AI, FilledSlotsFunc, modifiedFlag);

            Bots = builder.BotBuilder(Cg.AI, Slots, modifiedFlag);
            //Players = new PlayerManager(this);

            //Match = new MatchManager(this);


            //Logger = new MatchLogger(this);

            //Maps = new MapChooser(this, Map.A_HorizonLunarColony); //todolater get this from the user. Also need to load preset


            //Joins = new JoinManager(this);

            //Loop.AddPhaselessLoop(IncrementTime, 1);
        }
Exemple #16
0
        /// <summary>
        /// Collects this item.
        /// </summary>
        /// <param name="player">The player.</param>
        public override void Collect(IPlayer player)
        {
            base.Collect(player);

            // Force a fold of dimensional planes.
            PhaseManager.FoldPlane();
        }
 // Start is called before the first frame update
 void Start()
 {
     spriteRenderer  = GetComponent <SpriteRenderer>();
     gameManager     = GameObject.Find("GameManager").GetComponent <GameManager>();
     spawnController = GameObject.Find("SpawnManager").GetComponent <SpawnController>();
     phaseManager    = GameObject.Find("GameManager").GetComponent <PhaseManager>();
 }
Exemple #18
0
    /// <summary>
    /// Executes a phase of a specific index
    /// also runs the phase manager
    /// </summary>
    /// <param name="phase"></param>
    private void executePhase(int phase)
    {
        DebugControl.log("turn", "--PHASE " + phase);
        foreach (Ship ship in gameManager.getAllShips())
        {
            if (ship.getCanAct())
            {
                // checks for head on ramming where ships are in adjacent nodes
                if (!checkAdjHRam(ship, phase))
                {
                    ship.doAction(phase);
                }


                //if (ship.needRedirect && ship.team != GameManager.playerTeam)
                if (ship.NeedRedirect && ship.team.TeamType == Team.Type.ai)
                {
                    int newDirection = 0;
                    newDirection = ship.Ai.setNewShipDirection(ship);
                    ship.hold();
                    ship.setFront(newDirection);
                    ship.setSpriteRotation();
                }
            }
        }



        handleCollisions();
        handleCatapults();
        handleCapture();

        StartCoroutine(PhaseManager.playPhaseAnimations());
    }
Exemple #19
0
    public void StartGame(GameState gameState, PhaseManager phaseManager)
    {
        this.gameState    = gameState;
        this.phaseManager = phaseManager;

        phaseManager.NewTurn      += OnNewTurn;
        phaseManager.TurnEnding   += OnTurnEnding;
        phaseManager.GameStarting += OnGameStarting;

        LoadDecks();

        for (int i = 0; i < Constants.StartHandSize; ++i)
        {
            DrawCardIfPossible(gameState.HandOverlord, gameState.DeckOverlord, CardType.Room);
            DrawCardIfPossible(gameState.HandRunner, gameState.DeckRunner, CardType.Hero);
        }

        gameState.MaxManaRunner   = Constants.StartManaRunner;
        gameState.MaxManaOverlord = Constants.StartManaOverlord;

        roomManager = new RoomManager();
        roomManager.Init();

        heroManager = new HeroManager();
        heroManager.Init();

        effectManager = new EffectManager();
        effectManager.Init(roomManager);
    }
Exemple #20
0
 public void UnsetPhaseManager(PhaseManager oldManager)
 {
     // Unset only if we're actually leaving the current phase
     if (m_CurrentPhase == oldManager)
     {
         m_CurrentPhase = null;
     }
 }
Exemple #21
0
 /// <summary>
 /// Adds an animation for this ship to capture the port they are on
 /// Sets ship stats according to capture rules
 /// </summary>
 public void capturePort()
 {
     canActAfterCollision = false;
     canAct       = false;
     movedForward = false;
     momentum     = 0;
     PhaseManager.addCaptureAnimation(this);
 }
 public CombatPhase(PhaseManager phaseManager, PlayerUI playerUI, bool skipCombat, float countdownTime, FinishCountdownEvent finishCountdownEvent) : base(phaseManager)
 {
     _playerUI             = playerUI;
     _defeatScreen         = phaseManager.EndGameScreen;
     _skipCombat           = skipCombat;
     _countdownTime        = countdownTime;
     _finishCountdownEvent = finishCountdownEvent;
 }
Exemple #23
0
        void Start()
        {
            // Calculate the initial offset.
            offset = transform.position - target.position;

            phaseManager = GameObject.Find("HUDCanvas").GetComponent <PhaseManager> ();
            camera       = GetComponent <Camera>();
        }
Exemple #24
0
 public static PhaseManager GetInstance()
 {
     if (_instance == null)
     {
         _instance = new PhaseManager();
     }
     return(_instance);
 }
Exemple #25
0
    public void Init(string[] playerNames)
    {
        this._playerNames = playerNames;
        InitialPhaseManager init = new InitialPhaseManager();

        this.players = init.Create(playerNames, new List <StatoController>(this.States));
        PhaseManager.GetInstance().Begin();
    }
Exemple #26
0
 /// <summary>
 /// Changes camera focus to the ship that was just selected.
 /// </summary>
 void onShipSelection()
 {
     if (selected != null)
     {
         StartCoroutine(PhaseManager.Focus(selected.Position));
         selected.setIconString(selected.getNumeralID());
     }
 }
Exemple #27
0
 public void TMInit()
 {
     phaseManager = GetComponent <PhaseManager>();
     gameTimer    = gameTimeLimit;
     textMesh     = timerText.GetComponent <TextMesh>();
     textRed      = new Color(255f / 255f, 0f / 255f, 0f / 255f);
     textBlack    = new Color(0f / 255f, 0f / 255f, 0f / 255f);
 }
Exemple #28
0
 public NonMasterPositioningPhase(PhaseManager phaseManager, NetworkUIController networkUiController,
                                  CloudAnchorsExampleController cloudAnchorsController, NonMasterInstantiatingPhase instantiatingPhase) :
     base(phaseManager)
 {
     _networkUiController    = networkUiController;
     _cloudAnchorsController = cloudAnchorsController;
     _instantiatingPhase     = instantiatingPhase;
     _phaseManager           = phaseManager;
 }
 public MasterPositioningPhase(PhaseManager phaseManager, NetworkUIController networkUiController,
                               CloudAnchorsExampleController cloudAnchorsController, MasterInstantiatingPhase instantiatingPhase, bool skipAR) : base(
         phaseManager)
 {
     _networkUiController    = networkUiController;
     _cloudAnchorsController = cloudAnchorsController;
     _instantiatingPhase     = instantiatingPhase;
     _skipAR = skipAR;
 }
    public void OnClickBuy()
    {
        if (selected == null)
        {
            Debug.LogError("페이퍼 구입 선택 오류0");
        }

        if (selected <= ((int)E_Monster.MAX) - 1)   //몬스터 허가증인 경우
        {
            E_Monster mob = (E_Monster)selected;
            Debug.Log(mob);

            if (PhaseManager.GetInstance().IsOpen(mob))
            {
                Debug.Log("이미 열린것?");
                HideTab();
                ShowTab();
                return;
            }
            else
            {
                Debug.Log("몬스터 구입");
                PhaseManager.GetInstance().OpenMonsterCertificate(mob);
                GoldManager.GetInstance().AdjustGold(-1 * mpDic[(int)selected].price, GoldManager.E_PayType.BUY_BY_MERCHANT);
                HideTab();
                ShowTab();
                return;
            }
        }
        else
        {
            int eviNum = ((int)selected) - (((int)E_Monster.MAX) - 1);

            E_Evidence evi = (E_Evidence)eviNum;
            Debug.Log(evi);
            if (PhaseManager.GetInstance().IsOpen(evi))
            {
                Debug.Log("이미 열린것?");
                HideTab();
                ShowTab();
                return;
            }
            else
            {
                Debug.Log("증거품 구입");
                PhaseManager.GetInstance().OpenEvidenceCertificate(evi);
                GoldManager.GetInstance().AdjustGold(-1 * mpDic[(int)selected].price, GoldManager.E_PayType.BUY_BY_MERCHANT);
                HideTab();
                ShowTab();
                return;
            }
        }

        //인벤토리에 넣어주고.
        //골드 까주고.
    }
    void Init()
    {
        selected = null;
        miDic.Clear();

        buyBtn.interactable = false;
        nowGold             = GoldManager.GetInstance().Gold;
        nowGoldTxt.text     = nowGold.ToString();

        int miCount = (int)E_Interior.MAX;

        nowLang = LanguageManager.GetInstance().Language;
        //nowLang = E_Language.ENGLISH;

        for (int i = 0; i < miCount; i++)
        {
            string name    = "";
            string comment = "";
            int    price   = merchantInteriorSheet.dataArray[i].Price;
            switch (nowLang)
            {
            case E_Language.KOREAN:
                name    = merchantInteriorSheet.dataArray[i].Namekor;
                comment = merchantInteriorSheet.dataArray[i].Micmtkor;
                break;

            case E_Language.ENGLISH:
                name    = merchantInteriorSheet.dataArray[i].Nameeng;
                comment = merchantInteriorSheet.dataArray[i].Micmteng;
                break;
            }

            int num = i;

            GameObject btn = Instantiate(buyInteriorBtn, buyInteriorContent.transform);

            btn.GetComponent <Button>().onClick.AddListener(
                () =>
            {
                AudioThing.GetInstance().PlaySFX(AudioThing.E_SFX.CLICK);
                SelectInterior(num);
            }

                );
            miDic.Add(num, new miBtn((E_Interior)i, btn, name, price, comment));

            SetTxtsInteriorBtn(btn, price, name, (E_Interior)i);

            if (PhaseManager.GetInstance().IsOpen((E_Interior)i))
            {
                btn.GetComponent <Button>().interactable = false;
            }
        }
        ShowDefaultComment();
        GoldAdjustShow(0);
    }
Exemple #32
0
 public void SetPhaseManager(PhaseManager newManager, int debrisTotal)
 {
     m_CurrentPhase = newManager;
     m_DebrisTotal = debrisTotal;
     SyncDebrisProperties();
 }
Exemple #33
0
    /*****************************************************************************************
     *| GAME METHODS | COROUTINES |
     *****************************************************************************************/
    IEnumerator PreBeginPlay( )
    {
        //Debug
        while ( Application.loadedLevelName != MatchLevel )
        {
            yield return null;
        }

        //Initiate the grid system
        GridSystem.InitializeGrid( );

        //Initiate the actor manager
        ACTOR_MANAGER = gameObject.AddComponent<ActorManager>( );
        ActorManager.Instance = ACTOR_MANAGER;

        //Initiate the phase manager
        PHASE_MANAGER = gameObject.AddComponent<PhaseManager>( );

        while ( !GridSystem.IsInitialized )
        {
            yield return null;
        }

        //All systems done, we're now in game and loaded
        CurrentGameState = GameState.GAME;
        bInputEnabled = false;
        GameObject waitingModal = ModalWindow.Display( "WaitingForPlayersPanel" );

        while ( bInEvent )
        {
            yield return null;
        }

        //Set as ready
        Hashtable readyProperties = new Hashtable( )
        {
            {"Ready", true}
        };

        PhotonNetwork.player.SetCustomProperties( readyProperties );

        //On the server
        if ( PhotonNetwork.isMasterClient )
        {
            //Wait until all players are ready
            while ( !AllPlayersReady ) yield return null;

            //Transfer actor ownership
            int baseNum = 0;
            foreach ( PhotonPlayer p in PhotonNetwork.playerList )
            {
                PlayerBase baseToBeAssigned = PlayerBase.AllBases[ baseNum ];
                if ( baseToBeAssigned != null )
                {
                    //Raise PhotonView assignment event
                    byte evCode = 0;
                    int[] content = new int[]
                    {
                        baseToBeAssigned.photonView.viewID,
                        p.ID
                    };

                    RaiseEventOptions op = new RaiseEventOptions( );
                    op.Receivers = ExitGames.Client.Photon.ReceiverGroup.All;

                    PhotonNetwork.RaiseEvent( evCode, content, true, op );
                    baseNum++;
                }
            }

            //Once all players are ready, begin the game
            photonView.RPC( "RPCBeginGame", PhotonTargets.AllBuffered );

            //Destroy the modal
            GameObject.Destroy( waitingModal.gameObject );
        }
        else
        {
            //Wait until the game starts
            while ( !bGameStarted ) yield return null;
        }

        //Destroy the modal
        if ( waitingModal != null )
        {
            GameObject.Destroy( waitingModal.gameObject );
        }

        yield return null;
    }
    public static void ReadSceneFile(TextAsset file)
    {
        Manager = PhaseManager.Get();
        CurrentPhase = new Phase();

        Regex regex = new Regex(@"\t*");
        string temp = regex.Replace(file.text, "");
        regex = new Regex(@" {2,}");
        temp = regex.Replace(temp, " ");
        regex = new Regex(@" *= *");
        temp = regex.Replace(temp, "=");
        regex = new Regex(Environment.NewLine + @"{2,}");
        temp = regex.Replace(temp, "");

        StreamWriter newFile = new StreamWriter(Application.dataPath + @"\ParseFix.txt");
        newFile.Write(temp);
        newFile.Close();

        StreamReader fileReader = new StreamReader(Application.dataPath + @"\ParseFix.txt");

        while (!fileReader.EndOfStream)
        {
          ++CurrentLine;
          Debug.Log("Line #" + CurrentLine);

          string line = fileReader.ReadLine();

          if(String.IsNullOrEmpty(line) || line.Trim().Length == 0)
          {
        Debug.Log("Skipping: Empty Line");
        continue;
          }
          if (line.TrimStart().Substring(0, 2) == PP.COMMENT_LINE)
          {
        Debug.Log("Skipping: Comment Line");
        continue;
          }
          if (line == PP.PHASE_CLOSE)
          {
        Debug.Log("Phase Ended");
        Manager.AddPhase(CurrentPhase);
        CurrentPhase = null;
          }
          else
          {
        switch (line.GetWord(0, " "))
        {
          case PP.PHASE_OPEN:
          case PP.GLOBAL_OPEN:
            Debug.Log("Beginning New Phase");
            CurrentPhase = new Phase();
            break;
          case PP.GLOBAL_CLOSE:
            Manager.AddGlobalPhase(CurrentPhase);
            CurrentPhase = null;
            break;
          case PP.CUSTOM_EVENT_OPEN:
            string eName = line.GetWord(1, " ");
            eName = eName.SplitTextDelimited("=")[1];

            // Since Events can have prerequisite
            string preReqCheck = line.GetLastWord(" ");
            Debug.Log("PreReqs for " + eName + ": " + preReqCheck);
            if (preReqCheck.SplitTextDelimited("=")[0] == PP.PARAM_EVENT_REQ)
            {
              Debug.Log("PreReqs found");
              CreateCustomEvent(ref fileReader, eName, Int32.Parse(preReqCheck.SplitTextDelimited("=")[1]));
            }
            else
            {
              Debug.Log("No PreReqs found, defaulting.");
              CreateCustomEvent(ref fileReader, eName);
            }

            break;
          case PP.EVENT_BEGIN_PHASE:
          case PP.EVENT_ENTER_TRIGGER:
          case PP.EVENT_ITEM_PICKUP:
          case PP.EVENT_TIMER_COMPLETED:
            Debug.Log("Creating Event Watcher");
            CreateEventWatcher(line);
            break;
          case PP.EVENT_MATH_CONDITION:
            CurrentPhase.AddConditional(CreateConditional(line));
            break;
          case PP.OBJECT_TIMER:
          case PP.OBJECT_VARIABLE:
          case PP.OBJECT_SOUND:
            Debug.Log("Creating Object");
            CreateObject(line);
            break;
          case PP.PHASE_CLOSE:
            break;
          default:
            Debug.Log("Couldn't parse line: " + line);
            break;
        }
          }
        }

        fileReader.Close();
        File.Delete(Application.dataPath + @"\ParseFix.txt");
        Debug.Log("Parse Successful");
    }
    // Use this for initialization
    void Start()
    {
        hexController = GameObject.FindGameObjectWithTag("GameController").GetComponent<HexController>();
        boardManager = GameObject.FindGameObjectWithTag("GameController").GetComponent<BoardManager>();
        phaseManager = GameObject.FindGameObjectWithTag("GameController").GetComponent<PhaseManager>();
        specificBehavior = this.transform.GetComponent<SpecificBehavior>();
        currentHex = hexController.GetNearestHex(this.transform.position);

        //If already on the board, snap to nearest hex. Only use this during development
        //if (specificBehavior.active == BoardManager.Active.Board)

        SnapToNearest();
        this.transform.GetComponent<Rigidbody>().isKinematic = false;
    }
	void setSecondary(){
		switch (loadout.getSecondary ())
		{
		case Loadout.LoadoutSecondary.NULL:
			Debug.Log ("Secondary NULL");
			break;
		case Loadout.LoadoutSecondary.EMP:
			Debug.Log ("Secondary set EMP Counter");
			gameObject.AddComponent<EMPManager>();
			break;
		case Loadout.LoadoutSecondary.PHASING:
			Debug.Log ("Secondary set Phasing System");
			gameObject.AddComponent<PhaseManager> ();
			phaseOn = GetComponent<PhaseManager> ();
			phaseEquipped = true;
			break;
		case Loadout.LoadoutSecondary.TESLA:
			Debug.Log ("CSecondary set Mosquito Tesla Coil");
			gameObject.AddComponent<TeslaManager>();
			break;
		case Loadout.LoadoutSecondary.FREEZE:
			Debug.Log ("Secondary set Freeze Ray");
			gameObject.AddComponent<FreezeManager>();
			break;
		case Loadout.LoadoutSecondary.HOLOGRAM:
			Debug.Log ("Secondary set Holo Duplicate");
			gameObject.AddComponent<HoloManager>();
			break;
		default:
			Debug.Log ("Secondary not in range");
			break;
		}
	}
Exemple #37
0
 void Awake() {
   pm = this;
 }