Пример #1
0
    public void TickRogolf()
    {
        if (ball.InHole())
        {
            BoomBox.Play(Sound.SINK);
            game.SetState(new PostHoleState(game));
        }
        else
        {
            // TODO - debug
            List <Tuple <string, int> > scoreInfo = game.GetScore().AddShotScore();
            string s = string.Join(", ",
                                   (from item in scoreInfo select String.Format("{0}: {1}", item.Item1, item.Item2.ToString())));
            GodOfUI gui = GameObject.Find("UICanvas").GetComponent <GodOfUI>();
            gui.WriteBonus(s);
            gui.InvokeBonus(2f);

            int shotScore = (from item in scoreInfo select item.Item2).Sum();
            game.GetScore().AddCredit(shotScore);

            if (ball.InWater())
            {
                ball.Reset();
                game.GetHoleBag().GetCurrentHoleData().IncrementStrokes();
                BoomBox.Play(Sound.SPLASH);
            }

            game.SetState(new PrepareState(game));
        }
    }
Пример #2
0
    /// <summary>
    /// Performs initialization of Game object.
    /// </summary>
    public void Initialize(GameMode gameMode)
    {
        this.gameMode = gameMode;
        this.state    = new NoState(this);
        gc            = GameObject.Find(GameController.NAME).GetComponent <GameController>();

        // Initialize fields
        this.holeBag           = new HoleBag(gameMode);
        this.itemBag           = new ItemBag("good");
        this.badItemBag        = new ItemBag("bad");
        this.playerAttributes  = new PlayerAttributes();
        this.terrainAttributes = new TerrainAttributes();

        inputController = new InputController(this);
        target          = Target.BALL;

        wind            = new Wind(this);
        ball            = new Ball(this);
        cursor          = new Cursor(this);
        currentDistance = new CurrentDistance(this);
        bag             = new Bag(this);
        powerbar        = new Powerbar(this);
        shotMode        = new ShotMode(this);
        score           = new Score(this);

        // Send Game reference to other objects
        GodOfUI ui = GameObject.Find(GodOfUI.NAME).GetComponent <GodOfUI>();

        ui.gameRef = this;
    }
Пример #3
0
 public RunningState(Game game) : base(game)
 {
     this.ball            = game.GetBall();
     this.currentDistance = game.GetCurrentDistance();
     this.godOfUI         = GameObject.Find(GodOfUI.NAME).GetComponent <GodOfUI>();
 }