Пример #1
0
    public void HandleChange(object sender, NotifyCollectionChangedEventArgs e)
    {
        if (e.Action == NotifyCollectionChangedAction.Add)
        {
            foreach (GameObject ship in GetAllShipTypes((string)e.NewItems[0]))
            {
                ToggleShipSelection(ship);
            }
        }

        if (e.Action == NotifyCollectionChangedAction.Remove)
        {
            foreach (GameObject ship in GetAllShipTypes((string)e.OldItems[0]))
            {
                ToggleShipSelection(ship);
            }
        }


        if (e.Action == NotifyCollectionChangedAction.Reset)
        {
            BackgroundScript bgScript = GameObject.FindGameObjectsWithTag("spacebg")[0].GetComponent <BackgroundScript>();
            foreach (string ship in bgScript.GetOldShips())
            {
                foreach (GameObject shipObj in GetAllShipTypes(ship))
                {
                    ToggleShipSelection(shipObj);
                }
            }
        }
    }
    public void AlignToPrevious(BackgroundScript previous, BackgroundScript current)
    {
        Vector3 position = previous.transform.position;

        position.x = previous.transform.position.x + current.GetWidth() / 2 + previous.GetWidth() / 2;
        current.transform.position = position;
    }
Пример #3
0
 void Awake()
 {
     _pool       = GameObject.FindGameObjectWithTag("PoolManager").GetComponent <PoolManager>();
     _menu       = GameObject.FindGameObjectWithTag("Menu").GetComponent <MenuScript>();
     _background = GameObject.FindGameObjectWithTag("Background").GetComponent <BackgroundScript>();
     _spawn      = GameObject.FindGameObjectWithTag("Spawner").GetComponent <SpawnerScript>();
     _score      = GameObject.FindGameObjectWithTag("Scoreboard").GetComponent <ScoreboardScript>();
     _credit     = GameObject.FindGameObjectWithTag("Creditboard").GetComponent <CreditBoardScript>();
 }
Пример #4
0
 void Awake()
 {
     if (instance != null && instance != this) {
         Destroy(this.gameObject);
         return;
     } else {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Пример #6
0
 public void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Пример #7
0
    /// <summary>
    /// Instantiates all the tiles.
    /// </summary>
    /// <param name="map"></param>
    /// <param name="dividerLevel"></param>
    /// <param name="availiableTile"></param>
    protected virtual void InstantiateTiles(TileType[,] map, int dividerLevel, Dictionary <TileSetType, TileLevel> availiableTile, List <Vector2> spawnPoints)
    {
        for (int xdx = 0; xdx < map.GetLength(0); xdx++)
        {
            for (int ydx = 0; ydx < map.GetLength(1); ydx++)
            {
                TileType type = map[xdx, ydx];
                if (type != TileType.None && type != TileType.Lava)
                {
                    TileSetType level = ydx > dividerLevel ? TileSetType.upperLevels : TileSetType.lowerLevels;

                    GameObject obj  = availiableTile[level].GetTileType(type);
                    var        tile = (GameObject)Instantiate(obj, new Vector3(xdx * Tilesize, ydx * Tilesize), new Quaternion());

                    Debug.Log(tile);
                    NetworkServer.Spawn(tile);
                }
                else if (type == TileType.Lava)
                {
                    GameObject obj  = availiableTile[TileSetType.lava].GetTileType(TileType.Top);
                    var        tile = (GameObject)Instantiate(obj, new Vector3(xdx * Tilesize, ydx * Tilesize), new Quaternion());
                    tile.name = "Lava";
                    Debug.Log(tile);
                    NetworkServer.Spawn(tile);
                }

                //GameObject bck = availiableTile[TileSetType.background].GetTileType(TileType.Filler);
                //var backt = (GameObject)Instantiate(bck, new Vector3(xdx * Tilesize, ydx * Tilesize), new Quaternion());
                //backt.name = "background";
                //Debug.Log(backt);
                //NetworkServer.Spawn(backt);
            }
        }

        foreach (Vector2 point in spawnPoints)
        {
            var spawn = (GameObject)Instantiate(SpawnPrefab, new Vector3(point.x * Tilesize, point.y * Tilesize), new Quaternion());
            spawn.name = "spawnPoint";
            Debug.Log(spawn);
            NetworkServer.Spawn(spawn);
        }

        //GameObject back = backgroundPrefab;

        var backobj           = (GameObject)Instantiate(backgroundPrefab, new Vector3(0, 0, -1.5f), new Quaternion());
        BackgroundScript move = backobj.GetComponent(typeof(BackgroundScript)) as BackgroundScript;

        move.MapSize      = new Vector2(WidthSize * Tilesize, HeightSize * Tilesize);
        move.DividerLevel = dividerLevel;
        Debug.Log(backobj);
        NetworkServer.Spawn(backobj);
    }
Пример #8
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
    private BackgroundScript GetLastBackground()
    {
        BackgroundScript lastBackground = null;
        BackgroundScript currentBackground;

        for (int i = 0; i < this.backgrounds.Length; i++)
        {
            currentBackground = backgrounds [i];
            if (lastBackground == null || currentBackground.transform.position.x > lastBackground.transform.position.x)
            {
                lastBackground = currentBackground;
            }
        }
        return(lastBackground);
    }
Пример #10
0
        /// <summary>
        /// Changes the current active header. It also animates the location plate.
        /// </summary>
        /// <example>
        /// <<changeHeader fishMarket>>
        /// </example>
        /// <param name="parameters">1st element if the name for the header</param>
        private void ChangeHeader(string[] parameters)
        {
            if (parameters.Length != 1)
            {
                Debug.LogWarning("changeHeader has no parameters");
                return;
            }

            Debug.Log($"Change Header: {parameters[0]}");

            string searchTerm = parameters[0];

            foreach (var bg in _backgroundScriptList)
            {
                if (bg.IsSimilar(searchTerm))
                {
                    var previousBg = "";

                    if (_currentBg != null)
                    {
                        _currentBg.Disappear();
                        previousBg = _currentBg.CodeName;
                    }

                    _lastLocation = searchTerm;
                    _currentBg    = bg;
                    _currentBg.gameObject.SetActive(true);
                    _currentBg.Appear();
                    locationPlate.SetLocation(bg.DisplayName);

                    // special cases
                    // bad hard coding LMAO
                    if (searchTerm.ToLower().Equals("sunset"))
                    {
                        iconManager.UpdateAlternativeTextLocation(TextAlternativeLocationState.Sunset);
                    }

                    if (previousBg.ToLower().Equals("sunset"))
                    {
                        iconManager.UpdateAlternativeTextLocation(TextAlternativeLocationState.Default);
                    }

                    return;
                }
            }

            Debug.LogWarning($"Header not found: {parameters[0]}");
        }
Пример #11
0
	// checking bools objects. 
	
	
	// Use this for initialization
	void Start () 
	{
		Instance = this;
		player = GameObject.FindGameObjectWithTag("Player");
		playerScript = player.GetComponent<mainPlayer>();

		roadO = GameObject.FindGameObjectWithTag("MainCamera");
		roadScript = roadO.GetComponent<ForegroundScript>();
		
		currentLane = getRandomLane();
		prevLane = currentLane;
		getColor();
		currTime = 0;
		startTime = getStartTime();
	
		
	}
Пример #12
0
    void CreateBackground()
    {
        GameObject player = GameObject.Find("Ship");
        // Creating background holder
        GameObject obj = new GameObject("Background");

        obj.transform.position = Vector3.zero;
        // Creating  the backgrounds
        for (int i = 0; i < 3; i++)
        {
            GameObject     objSub = new GameObject("Background");
            SpriteRenderer sr     = objSub.AddComponent <SpriteRenderer>();
            sr.sprite = backSprite;
            objSub.transform.localScale = new Vector3(2, 2, 1);
            objSub.transform.parent     = obj.transform;
            BackgroundScript bs = objSub.AddComponent <BackgroundScript>();
            bs.player = player.transform;
            Vector3 pos = Vector3.zero;
            pos.x = 20 * i;
            objSub.transform.localPosition = pos;
        }
    }
Пример #13
0
 void Start()
 {
     BS              = GameObject.Find("Buttons").GetComponent <ButtonScript>();
     BG1             = GameObject.Find("BG1").GetComponent <BackgroundScript>();
     BG2             = GameObject.Find("BG2").GetComponent <BackgroundScript>();
     BG3             = GameObject.Find("BG3").GetComponent <BackgroundScript>();
     BG4             = GameObject.Find("BG4").GetComponent <BackgroundScript>();
     image1          = GameObject.Find("Button1").GetComponent <Image>();
     image2          = GameObject.Find("Button2").GetComponent <Image>();
     image3          = GameObject.Find("Button3").GetComponent <Image>();
     HS              = GameObject.Find("Score").GetComponent <HighscoreScript>();
     player          = GameObject.FindGameObjectWithTag("player");
     retry           = GameObject.Find("Retry").GetComponent <Image>();
     rText           = GameObject.Find("retry").GetComponent <MeshRenderer>();
     menu            = GameObject.Find("Menu").GetComponent <Image>();
     mText           = GameObject.Find("menu").GetComponent <MeshRenderer>();
     bite            = GameObject.Find("monster").GetComponent <AudioSource>();
     Music           = GameObject.Find("MonsterHB").GetComponent <AudioSource>();
     monsterMoveRend = GameObject.Find("Monster").GetComponent <SpriteRenderer>();
     monsterMoveAnim = GameObject.Find("Monster").GetComponent <Animator>();
     monsterFallRend = GameObject.Find("monster").GetComponent <SpriteRenderer>();
     monsterFallAnim = GameObject.Find("monster").GetComponent <Animator>();
 }
Пример #14
0
    void Start()
    {
        BUTTON1.enabled = false;
        BUTTON2.enabled = false;
        BUTTON3.enabled = false;
        BUTTON4.enabled = false;
        BUTTON5.enabled = false;
        BUTTON6.enabled = false;

        index          = Random.Range(0, 3);
        grow           = false;
        start          = true;
        wait           = 0.5f;
        count          = 0f;
        sound          = GetComponent <AudioSource>();
        image          = GetComponent <Image>();
        AS             = GameObject.Find("Info").GetComponent <AddScript>();
        RS             = GameObject.Find("Buttons").GetComponent <RandomScript>();
        BG1            = GameObject.Find("BG1").GetComponent <BackgroundScript>();
        BG2            = GameObject.Find("BG2").GetComponent <BackgroundScript>();
        BG3            = GameObject.Find("BG3").GetComponent <BackgroundScript>();
        BG4            = GameObject.Find("BG4").GetComponent <BackgroundScript>();
        image1         = GameObject.Find("Button1").GetComponent <Image>();
        image2         = GameObject.Find("Button2").GetComponent <Image>();
        image3         = GameObject.Find("Button3").GetComponent <Image>();
        image4         = GameObject.Find("Button4").GetComponent <Image>();
        image5         = GameObject.Find("Button5").GetComponent <Image>();
        image6         = GameObject.Find("Button6").GetComponent <Image>();
        image7         = GameObject.Find("Button7").GetComponent <Image>();
        monster        = GameObject.Find("MonsterHB").GetComponent <MonsterScript>();
        HS             = GameObject.Find("Score").GetComponent <HighscoreScript>();
        playerMoveRend = GameObject.Find("Player").GetComponent <SpriteRenderer>();
        playerMoveAnim = GameObject.Find("Player").GetComponent <Animator>();
        playerFallRend = GameObject.Find("player").GetComponent <SpriteRenderer>();
        PlayerFallAnim = GameObject.Find("player").GetComponent <Animator>();
    }
Пример #15
0
 // Use this for initialization
 void Start()
 {
     script = GameObject.Find("BackgroundProcess").GetComponent <BackgroundScript>();
 }
Пример #16
0
 public void Awake()
 {
     instance = this;
     active   = PlayerPrefs.GetString("BackgroundScript_active", "True") == "True";
 }
Пример #17
0
 // Use this for initialization
 void Start()
 {
     BackgroundManager = this;
 }
Пример #18
0
 void Awake()
 {
     background = FindObjectOfType<BackgroundScript>();
     prompt = FindObjectOfType<PromptScript>();
 }
Пример #19
0
        /// <summary>
        /// Called on during creation
        /// </summary>
        public virtual void Start()
        {
            // Add a background image
            Texture2D testBackground = Loader.LoadTexture(@"Z:\SkyDrive\Development\Workspace\trunk\beats2n\Assets\Resources\Common\Game\Background.jpg", false);
            background = BackgroundScript.Init(Display.centre, testBackground, Display.height);

            // Add an FPS counter
            UIFont uiFont = UITools.CreateFont(testFont, 30);
            fpsCounter = FpsCounterScript.Init(uiFont);
        }
    public void OnOutOfCamera(BackgroundScript background)
    {
        BackgroundScript lastBackground = GetLastBackground();

        AlignToPrevious(lastBackground, background);
    }