Start() public method

public Start ( ) : void
return void
Exemplo n.º 1
0
    void Start()
    {
        phase = 0;
        mCountdown.Start();
        mTransitionCd.Start();

        if (GameManager.Instance.Level > 0)
        {
            // no tutorial
            this.enabled = false;
        }
    }
Exemplo n.º 2
0
        void Start()
        {
            // load level instructions
            TextAsset ta = (TextAsset)Resources.Load("Level" + GameManager.Instance.Level);

            if (ta == null)
            {
                Debug.LogError("Can't find level asset for level " + GameManager.Instance.Level);
                return;
            }

            string[] lines  = ta.text.Replace("\r", "").Split(new char[] { '\n' });
            int      lineNo = 0;

            foreach (string line in lines)
            {
                ++lineNo;
                if (line.Trim().Length > 0 && !line.Trim().StartsWith("#"))
                {
                    mScript.Add(line.Trim());
                    if (line.StartsWith(":"))
                    {
                        // this is an entry point -- record it
                        mScriptEntryPoints.Add(mScript.Count - 1);
                        mScriptEntryPointProbWeight.Add(System.Convert.ToInt32(line.Substring(1)));
                    }
                }
            }

            // prepare the dictionary that maps name --> prefab
            foreach (GameObject prefab in SpawnablePrefabs)
            {
                mPrefabDict[prefab.name] = prefab;
            }

            // start the level timer
            mLevelTime.Start();

            // start the gameplay reporting timer (for achievement unlocking purposes)
            mGameplaySecondCd.Start();

            // select the music for this level and start playing it
            if (BgmChoices.Length > 0)
            {
                AudioClip bgm = BgmChoices[GameManager.Instance.Level % BgmChoices.Length];
                GetComponent <AudioSource>().clip = bgm;
                GetComponent <AudioSource>().Play();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Event start
        /// </summary>
        /// <param name="seconds">Start parameter</param>
        public void SimulateTimeOut(int seconds)
        {
            Countdown.Start(seconds);
            var e = new NewTimeOutEventArgs(seconds);

            OnNewTimeOut(e);
        }
 /// <summary>
 /// Resets the character to its spawn location/setup. Ends with countdown and a callback to begin playing.
 /// </summary>
 public void Respawn()
 {
     gameObject.SetActive(true);
     Reset();
     StartCoroutine(DoBlinks(0.5f));
     StartCoroutine(MakeInvulnerable());
     StartCoroutine(countdown.Start(0.5f, Unfreeze));
 }
Exemplo n.º 5
0
 //开始追踪
 void TrackPos(Vector2 pos)
 {
     if (TrackAction.IsTracking == false &&
         trackCd.IsOver == true)
     {
         TrackAction.SetTarger(pos);
         trackCd.Start();
     }
 }
Exemplo n.º 6
0
    void Start()
    {
        phase = 0;
        mCountdown.Start();
        mTransitionCd.Start();

        bool hasController = Input.GetJoystickNames().Length > 0;

        // skip over the touch interface steps if using a controller.
        if (hasController)
        {
            phase = 3;
        }
        if (GameManager.Instance.Level > 0)
        {
            // no tutorial
            this.enabled = false;
        }
    }
    void OnEnable()
    {
        mTransition.Start();
        PilotStatsGUI g = gameObject.GetComponent <PilotStatsGUI>();

        if (g != null)
        {
            g.ShowPilotLevel = false;
        }
    }
Exemplo n.º 8
0
        void CheckLevelCleared()
        {
            if (IsPlaying && mLevelTime.Expired &&
                GameObject.FindGameObjectsWithTag("Enemy").Length == 0)
            {
                // level cleared!
                mGameState = GameState.Won;
                mAutoAdvanceCountdown.Start(GameConsts.AutoAdvanceTime);

                // did the player finish with 100% accuracy? If so, unlock achivement
                if (mShotsHit >= mShotsTotal)
                {
                    GameManager.Instance.UnlockAchievement(GameIds.Achievements.PerfectAccuracy);
                }

                GetComponent <AudioSource>().Stop();
                AudioSource.PlayClipAtPoint(LevelClearSfx, Vector3.zero);
            }
        }
Exemplo n.º 9
0
 void TakeDamage()
 {
     // take damage, but don't die yet
     if (!mHurtColorCountdown.Active)
     {
         ToggleHurtColor(true);
     }
     mHurtColorCountdown.Start();
     AudioSource.PlayClipAtPoint(TakeDamageSfx, Vector3.zero);
 }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            // Delegates. Lambdas and Events. Task 3.
            // Countdown demo.
            var timer          = new Countdown();
            var messageService = new MessageService();
            var mailService    = new MailService();

            timer.TimeElapsed += messageService.OnTimeElapsed;
            timer.TimeElapsed += mailService.OnTimeElapsed;
            timer.Start(3000);
        }
    //---------------------------------------------------------------------------------------
    //------------------------------------- Game --------------------------------------------
    //---------------------------------------------------------------------------------------
    // Use this for initialization
    void Start()
    {
        this.race      = new Race(raceDistance, playerCar, opponentCar, opponentRpmTolerance, displayRaceResults);
        this.countdown = new Countdown(displayCountdown, race);
        this.cluster.SetCar(playerCar);

        this.playerCar.positionAtGroundLevel(startingGround, true, false, 0.2);
        this.opponentCar.positionAtGroundLevel(startingGround, false, true, 0.2);

        race.Start();
        countdown.Start();
    }
Exemplo n.º 12
0
        private static void CountdownElapsed(Object sender, System.Timers.ElapsedEventArgs e)
        {
            if (!Directory.Exists("./data/timers"))
            {
                Directory.CreateDirectory("./data/timers");
                return;
            }

            //knowing that it exists, proceed to read contents

            if (Directory.GetFiles("./data/timers").Length == 0)
            {
                return;
            }

            //ok, it exists and has file contents. time to read.

            List <Timer> ActiveTimers = new List <Timer>();

            StreamReader reader = null;

            foreach (String s in Directory.GetFiles("./data/timers"))
            {
                //keep this from throwing a fatal error
                //if an exception occurs, it just means the timer adding procedure took a little longer than usual
                try
                {
                    reader = new StreamReader(File.OpenRead(s));
                    ActiveTimers.Add(JsonConvert.DeserializeObject <Timer>(reader.ReadToEnd()));
                    reader.Close();
                }
                catch { }
            }

            foreach (Timer t in ActiveTimers)
            {
                if (t == null)
                {
                    continue;
                }
                if (!t.CheckExpiry())
                {
                    continue;
                }
                else
                {
                    return;
                }
            }

            Countdown.Start();
        }
Exemplo n.º 13
0
 private void button1_Click(object sender, EventArgs e)
 {
     SynchronizationContextWrapper.SynchronizationContext = SynchronizationContext.Current;
     if (_countdown.IsStarted)
     {
         _countdown.Stop();
     }
     else
     {
         button1.Text = "5";
         _countdown.Start(5000); //Countdown from 5 with a 1 second interval.
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// Place the duelist in the arena and start the countdown
        /// </summary>
        private void StartRound()
        {
            m_RoundStart = true;

            m_Duelist1.MoveToWorld(m_Stone.DuelLoc1, m_Stone.ArenaMap);
            m_Duelist1.Paralyzed = true;

            m_Duelist2.MoveToWorld(m_Stone.DuelLoc2, m_Stone.ArenaMap);
            m_Duelist2.Paralyzed = true;

            Countdown c = new Countdown(this);

            c.Start();
        }
Exemplo n.º 15
0
    void CheckFireShot()
    {
        // update fire countdown
        mFireCountdown.Update(Time.deltaTime, true);

        // if the fire countdown is still going on, can't fire
        if (mFireCountdown.Active)
        {
            // can't fire now!
            return;
        }

        // check if player wants to fire a shot
        bool wantToFire = false;

        if (Input.touchCount > 0)
        {
            // a touch on the right side of the screen means "fire"
            foreach (Touch t in Input.touches)
            {
                if (t.position.x > Screen.width / 2)
                {
                    wantToFire = true;
                    break;
                }
            }
        }
        else
        {
            wantToFire = Input.GetButton("Fire1");
        }

        if (wantToFire)
        {
            // create the laser object
            int        idx   = Util.Clamp(mStats.Damage - 1, 0, LaserPrefab.Length - 1);
            GameObject laser = (GameObject)Instantiate(LaserPrefab[idx]);

            // position it
            laser.transform.Translate(0, gameObject.transform.position.y, 0, Space.World);

            // start the countdown
            mFireCountdown.Start(mStats.FireCooldown);

            // play the sound
            AudioSource.PlayClipAtPoint(LaserSfx, Vector3.zero);
        }
    }
Exemplo n.º 16
0
        // perform a minimax search from the current board to try and select the best move
        public MoveGen.MoveBoardPair Search(Board root, int depth, int qDepth, int alpha, int beta, TimeSpan time)
        {
            // guards
            if (depth < 1 || qDepth < 1)
            {
                throw new ArgumentException("valid depth limits are greater than zero");
            }
            if (alpha > beta)
            {
                throw new ArgumentException("alpha cannot be greater than beta");
            }

            // start countdown
            Countdown.Interval = time.TotalMilliseconds;
            Countdown.Start();

            Node RootNode = new Node(root);

            Node.TopLevelActivePlayerWhite = root.ActiveColorWhite; // store for utility eval

            MoveGen.MoveBoardPair Result = null;
            int Value = int.MinValue;
            int NextDepth;

            for (int d = 1; d <= depth; d++)   // step through depths
            {
                NextDepth = d - 1;
                foreach (Node child in RootNode.Children)   // step through children
                {
                    if (Result == null)
                    {
                        Result = new MoveGen.MoveBoardPair(child.Board, child.LastMove);                 // default to first move
                    }
                    if (Timeout)
                    {
                        return(Result);                                  // return best move if timed out
                    }
                    Value = MinV(child, NextDepth, qDepth, alpha, beta); // get minimized value from new board
                    if (Value > alpha)
                    {
                        alpha = Value; Result = new MoveGen.MoveBoardPair(child.Board, child.LastMove);
                    }                                                                                                      // update alpha and best move if better val found
                }
            }

            return(Result);
        }
Exemplo n.º 17
0
        void ExecuteNextInstruction()
        {
            if (mScriptIp >= mScript.Count)
            {
                JumpScriptToRandomEntryPoint();
                return;
            }

            string instr = mScript[mScriptIp++];

            if (instr.StartsWith(":"))
            {
                // this is a label, so skip it
                return;
            }

            string[] p    = instr.Split(new char[] { ' ' }, 2);
            string   verb = p.Length > 0 ? p[0].Trim() : "";
            string   arg  = p.Length > 1 ? p[1].Trim() : "";

            if (verb.Equals("spawn"))
            {
                ExecuteSpawn(arg);
            }
            else if (verb.Equals("wait"))
            {
                ExecuteWait(arg);
            }
            else if (verb.Equals("end"))
            {
                JumpScriptToRandomEntryPoint();
            }
            else if (verb.Equals("dur"))
            {
                mLevelTime.Start(System.Convert.ToSingle(arg));
            }
            else if (verb.Equals("msg"))
            {
                mMessage = arg.Trim();
                mMessageCd.Start();
            }
            else
            {
                Debug.LogError("Invalid instruction: " + arg);
            }
        }
Exemplo n.º 18
0
        public override void Load( )
        {
            base.Load( );

            map = new Map(this, new Container(new Margin(0f, 1f, 0f, .3f), MarginType.Relative, Position.Left | Position.Top), -10);

            stageProgressBar = new ProgressBar(this, new Container(new Margin(0f, 1f, 0.9875f, 0.0125f), MarginType.Relative), 10)
            {
                Max = 5, Value = 1
            };
            multiplierBar = new ProgressBar(this, new Container(new Margin(0, 1f, 0, 0.0125f), MarginType.Relative), 50)
            {
                Max = 10, Value = multiplier, Color = Color.Gold
            };
            healthLeftBar = new ProgressBar(this, new Container(new Margin(0f, 1f, 0.3f, 0.05f), MarginType.Relative), 50)
            {
                Max = 1, Value = 1, Color = new Color(255, 20, 20, 255)
            };

            goldLabelAligner   = new Aligner(this, new Container(new Margin(0.2f, 0f, 0f, 0f), MarginType.Absolute, Position.Left | Position.Top, Position.Left | Position.Top));
            damageLabelAligner = new Aligner(this, new Container(new Margin(0, 0.2f, 0f, 0f), MarginType.Absolute, Position.Right | Position.Top, Position.Right | Position.Top));

            swoosh = new Swoosh(this, new Container(new Margin(0.4f, 0.4f, 0.05f, 0.6f), MarginType.Absolute, Position.Top, Position.Top), 1);

            CoinLabel goldLabel = new CoinLabel(this, new Container(new Margin(0, 0.025f), MarginType.Absolute, anchor: Position.Center | Position.Top, dock: Position.Center | Position.Bottom, relative: multiplierBar), 0.05f, 75, Label.TextAlignment.Left);

            Label stageLabel = new Label(this, new Container(new Margin(0.025f, 0.025f), MarginType.Absolute, anchor: Position.Top | Position.Right, dock: Position.Right | Position.Bottom, relative: multiplierBar), 0.09f, Manager.State.Stage.ToString( ), new Color(100, 100, 100, 100), 75, Label.TextAlignment.Right);

            Manager.State.StageChanged += (newStage) => {
                stageLabel.Text = newStage.ToString( );
            };

            targetArea = new TargetArea(this, new Container(new Margin(0f, 1f, 0.35f, 0.625f), MarginType.Relative, Position.Left | Position.Top), 0, ChallengeProgressCallback, GetTapChallenge);

            countdown = new Countdown(this, new Container(new Margin(0f, 1f, 0.35f, 0.625f), MarginType.Relative), 10, 0.2f, 3);

            countdown.Finished += () => {
                Start( );
            };

            EntityRenderer.VertexSize = map.Container.Height / 3f;

            Prepare( );
            countdown.Start( );
        }
Exemplo n.º 19
0
        private static void CountdownElapsed(Object sender, System.Timers.ElapsedEventArgs e)
        {
            for (int i = 0; i < Active.Count; i++)
            {
                if (Active[i] == null)
                {
                    continue;
                }

                Boolean toRemove = Active[i].CheckExpiry();

                if (toRemove)
                {
                    Active.RemoveAt(i);
                }
            }

            Countdown.Start();
        }
Exemplo n.º 20
0
        public static void AddTimer(Timer timer)
        {
            Countdown.Stop();

            StreamWriter writer;

            if (!File.Exists($"./data/timers/{timer.Identifier}"))
            {
                File.Create($"./data/timers/{timer.Identifier}").Close();
            }
            writer = new StreamWriter(File.Open($"./data/timers/{timer.Identifier}", FileMode.Truncate));

            writer.Write(JsonConvert.SerializeObject(timer));

            writer.Close();

            Thread.Sleep(50);
            Countdown.Start();
        }
Exemplo n.º 21
0
        /// <summary>
        /// Event handler for "Next" button in GUI
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (!hasGuessed)
            {
                int num = Int32.Parse(txtAttempts.Text);
                num++;
                txtAttempts.Text = num.ToString();
            }
            hasGuessed = false;
            int n = 15;

            isZero = false;
            lblTimeRemaining.Text = n.ToString();
            TimeLeft = 15;
            Countdown.Start();
            lblQuestion.Text  = "What is the capital of " + StateNames[r.Next(0, StateNames.Count - 1)] + "?";
            btnChoose.Enabled = true;
            lblright.Visible  = false;
            lblwrong.Visible  = false;
        }
Exemplo n.º 22
0
    void Start()
    {
        point = this.transform.FindChild("point");
        Transform b = this.transform.parent.FindChild("b");

        bullet         = b.transform.FindChild("bullet");
        bulletExploder = b.transform.FindChild("bulletExploder");
        barPoint       = this.transform.FindChild("barPoint");
        bullet.gameObject.SetActive(false);
        startDir = this.transform.forward;

        moveCD = new Countdown(GetStopMoveTime(), OnEnd_StopMove, OnUpdate_StopMove);
        moveCD.Start(true);

        for (int i = 0; i < 3; i++)
        {
            bulletDataDic.Add(i * 3, GetColor());
            list_Vector3.Add(Vector3.one * i);
            list_class.Add(new Countdown(i * 3));
            list_int.Add(i * 3);
        }
    }
Exemplo n.º 23
0
        public int ReportKill(int score, float enemyX)
        {
            // increase combo counter
            mCombo++;
            mComboCd.Start();

            // calculate actual value of kill and add it to the score
            int actualValue = (int)(score * GetComboMult());

            mScore += actualValue;

            // add experience point to player
            if (GameManager.Instance.Progress.AddPilotExperience(1))
            {
                // level up! Inform player of this fact.
                GameObject player = GameObject.FindGameObjectWithTag("Player");
                player.GetComponent <PlayerController>().HandleLevelUp();
            }

            // unlock any achievements as appropriate
            UnlockKillRelatedAchievements(enemyX);

            return(actualValue);
        }
Exemplo n.º 24
0
 void Start()
 {
     mTransitionCd.Start();
 }
Exemplo n.º 25
0
 void OnEnd_Move()
 {
     moveCD = new Countdown(GetStopMoveTime(), OnEnd_StopMove, OnUpdate_StopMove, 0.9f, OnPer_StopMove);
     moveCD.Start(true);
 }
Exemplo n.º 26
0
 void OnEnd_StopMove()
 {
     moveCD = new Countdown(GetMoveTime(), OnEnd_Move, OnUpdate_Move);
     moveCD.Start(true);
     this.nowSpeed = GetSpeed();
 }
Exemplo n.º 27
0
 void ExecuteWait(string arg)
 {
     mCountdownToNextInstruction.Start(System.Convert.ToSingle(arg));
 }
Exemplo n.º 28
0
        /// <summary>
        /// Place the duelist in the arena and start the countdown
        /// </summary>
        private void StartRound()
        {
            m_RoundStart = true;

            m_Duelist1.MoveToWorld(m_Stone.DuelLoc1, m_Stone.ArenaMap);
            m_Duelist1.Paralyzed = true;

            m_Duelist2.MoveToWorld(m_Stone.DuelLoc2, m_Stone.ArenaMap);
            m_Duelist2.Paralyzed = true;

            Countdown c = new Countdown(this);
            c.Start();
        }
Exemplo n.º 29
0
        public static void ReenableTimer()
        {
            Thread.Sleep(250);

            Countdown.Start();
        }
Exemplo n.º 30
0
 void OnEnable()
 {
     mTransition.Start();
 }
Exemplo n.º 31
0
 private void StartCountdown(object sender, EventArgs e)
 {
     countdown.Start();
 }