示例#1
0
    public void Initialize(FieldManager _fieldManager, GameManager _gameManager, FruitManager _fruitManager)
    {
        fieldManager = _fieldManager;
        gameManager  = _gameManager;
        fruitManager = _fruitManager;
        audioSource  = GetComponent <AudioSource> ();
        growed       = false;
        Vector3[] directions = new Vector3[4];
        directions [0] = Vector3.right;
        directions [1] = Vector3.left;
        directions [2] = Vector3.forward;
        directions [3] = Vector3.back;

        newDirection = directions [(int)Random.Range(0, 3)];

        List <Vector3> snakePos = fieldManager.GetInstance().SetSnakePosition(newDirection);

        for (int i = 0; i < snake.Count; i++)
        {
            snake [i].transform.position = snakePos [i];
            if (newDirection == Vector3.forward || newDirection == Vector3.back)
            {
                snake [i].transform.rotation = Quaternion.Euler(new Vector3(0, 90, 0));
            }
            else
            {
                snake [i].transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0));
            }
            fieldManager.GetInstance().field[(int)snakePos [i].z, (int)snakePos [i].x] = 1;
        }
        InvokeRepeating("Move", 0.3f, 0.3f);
    }
示例#2
0
    private void Awake()
    {
        Instance      = this;
        _sceneChanger = this.GetComponent <SceneChanger>();

        _fruitManager    = this.GetComponent <FruitManager>();
        _uiManager       = this.GetComponent <UiManager>();
        _soundManager    = this.GetComponent <SoundManager>();
        _gameModeManager = this.GetComponent <GameModeManager>();

        _dots   = new List <Dot>();
        _ghosts = new List <Ghost>();

        /* Will select the stage settings relative to current Stage */
        if (Stage < settings.SequenceOfStageSettings.Length)
        {
            _stageSettings = settings.SequenceOfStageSettings[Stage];
        }
        else
        {
            int lastIndex = settings.SequenceOfStageSettings.Length - 1;
            _stageSettings = settings.SequenceOfStageSettings[lastIndex];
        }

        _gameModeManager.settings      = settings;
        _gameModeManager.stageSettings = _stageSettings;

        /* Will get the fruit to update on GUI */
        Fruit fruit = _fruitManager.GetFruitByType(_stageSettings.fruitType);

        _uiManager.FruitOnGUI(fruit.GetSprite());
        _uiManager.LifesOnGUI(Life);
        _uiManager.ScoreOnGUI(Score);
        _uiManager.HighScoreOnGUI(PlayerPrefs.GetInt(settings.HighScoreKeyPlayerPrefs, 0));
    }
示例#3
0
    public FruitManager GetInstance()
    {
        if (instance == null)
        {
            instance = this;
        }

        return(instance);
    }
示例#4
0
 private void Start()
 {
     if (!instance)
     {
         instance = this;
         InitializeDictationary();
         DontDestroyOnLoad(this);
     }
     else if (instance == this)
     {
         Destroy(gameObject);
     }
 }
示例#5
0
 // Snake should know how much fruits there are and generate enough snake tails.
 // again, this is snake, so we don't need to check who's the one bumpin'.
 // But we need to refer to snake to grow it a tail.
 // Or, if I had a better idea about HOW TO EFFIN CODE...
 void Awake()
 {
     instance = this;
 }
示例#6
0
 void Awake()
 {
     // Store game manager reference
     gameManager  = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();
     fruitManager = fruitLayer.GetComponent <FruitManager>();
 }
示例#7
0
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);

            manager = new FruitManager(new MemoryFruitDataManager());
        }
 void Awake()
 {
     _instance = this;
 }
示例#9
0
 public FruitTests()
 {
     dataManager = GetDataManager();
     manager     = new FruitManager(dataManager);
 }