Example #1
0
    // Use this for initialization
    void Start()
    {
        _background = GameObject.FindGameObjectWithTag("World")
            .GetComponent<BackgroundScrolling>();

        if(MatePrefabs == null || MatePrefabs.Length == 0)
        {
            Debug.LogError("No prefabs set on Mate Spawner");
        }
    }
Example #2
0
    // Start is called before the first frame update
    void Start()
    {
        backgroundScrolling = background.GetComponent <BackgroundScrolling>();
        obtaclesScrolling   = obtacles.GetComponent <ObstaclesScrolling>();
        groundScrolling     = ground.GetComponent <GroundScrolling>();

        dict[0] = 3f;
        dict[1] = 3.5f;
        dict[2] = 4f;
        dict[3] = 4.5f;
        dict[4] = 5f;
        dict[5] = 5.5f;
        dict[6] = 6f;
        dict[7] = 6.5f;

        obtaclesScrolling.speed = dict[0];
        groundScrolling.updateSpeed();
    }
Example #3
0
 // Use this for initialization
 void Start()
 {
     var world = GameObject.FindGameObjectWithTag("World");
     _scroller = world.GetComponent<BackgroundScrolling>();
 }
 // Start is called before the first frame update
 void Start()
 {
     timeBtwSpawns     = timeLimits.x;
     campfire.position = spawnPosition;
     campFire_scroll   = campfire.gameObject.GetComponent <BackgroundScrolling>();
 }
Example #5
0
    void Update()
    {
        if (bgScnLoading.isDone && !bgIsSet && loadPlayers.isDone && loadPlayers.isDone)
        {
            enemyScene  = SceneManager.GetSceneByName(enemieScene);
            bgScene     = SceneManager.GetSceneByName(backgroundScene);
            playerScene = SceneManager.GetSceneByName("Players");
            Debug.Assert(enemyScene.IsValid());
            Debug.Assert(bgScene.IsValid());
            Debug.Assert(playerScene.IsValid());

            GameObject gobj = GameObject.FindGameObjectWithTag("BG");
            Debug.Assert(gobj);
            BackgroundScrolling bgs = gobj.GetComponent <BackgroundScrolling>();
            Debug.Assert(bgs);
            gobj = GameObject.FindGameObjectWithTag("Party");
            PartyStat partyStat = gobj.GetComponent <PartyStat>();
            Debug.Assert(partyStat);
            bgs.SetLevelBackground(partyStat.m_currentLevelIdx);
            bgIsSet = true;
        }

        if (firstUpdate)
        {
            if (loadPlayers.isDone == false)
            {
                return;
            }
            firstUpdate = false;
            GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
            foreach (GameObject p in players)
            {
                m_players[p.GetComponent <PlayerController>().playerIndex] = p;
            }

            GameObject gameObject = GameObject.FindGameObjectWithTag("Game");
            GameState  game       = gameObject.GetComponent <GameState>();
            for (int i = 0; i < 4; ++i)
            {
                if (game.playerAreIA[i])
                {
                    m_players[i].GetComponent <PlayerInput>().enabled = false;
                }
                else
                {
                    m_players[i].GetComponent <PlayerIA>().enabled = false;
                }
            }
        }
        GameObject partyObject = GameObject.FindGameObjectWithTag("Party");
        PartyStat  party       = partyObject.GetComponent <PartyStat>();

        if (party.altitude >= distanceToReach)
        {
            party.EndLevelReached();
            distanceToReach = float.MaxValue;
        }

        foreach (GameObject p in m_players)
        {
            Debug.Assert(party);
            //Debug.Assert(p);
            if (p)
            {
                Debug.Assert(p.GetComponent <PlayerController>());
                if (party.droppedPlayers.Contains(p.GetComponent <PlayerController>().playerIndex))
                {
                    p.SetActive(false);
                }
            }
        }

        foreach (int playerIndex in party.droppedPlayers)
        {
            if (monsterPlayers[playerIndex] == null)
            {
                float spawnProp = Random.Range(0f, 1);
                if (spawnProp < Time.deltaTime)
                {
                    BoxCollider2D spawnCollider = gameObject.GetComponent <BoxCollider2D>();
                    float         x             = Random.Range(-spawnCollider.size.x / 2f, spawnCollider.size.x / 2f);
                    float         y             = Random.Range(-spawnCollider.size.y / 2f, spawnCollider.size.y / 2f);
                    Vector3       pos           = gameObject.transform.position + new Vector3(x, y, 0);
                    GameObject    newMonster    = Instantiate(monsterPlayerPrefab, pos, Quaternion.identity);
                    newMonster.GetComponent <MonsterInput>().playerIndex = playerIndex;
                    //MonsterController ai = newMonster.GetComponent<MonsterController>();

                    // Debug.Log("Spawn ghost " + playerIndex.ToString());

                    GameObject   playerObj = m_players[playerIndex];
                    PlayerInput  player    = playerObj.GetComponent <PlayerInput>();
                    MonsterInput mi        = newMonster.GetComponent <MonsterInput>();
                    mi.m_moveXAxis = player.m_moveXAxis;
                    mi.m_moveYAxis = player.m_moveYAxis;
                    mi.m_fireXAxis = player.m_fireXAxis;
                    mi.m_fireYAxis = player.m_fireYAxis;
                }
            }
        }
    }
Example #6
0
 // removes background from the list - this is public so that the background scrolling script attached to each background can call this function
 // when it collides with the background deleter
 public void RemoveFromList(BackgroundScrolling thisComp)
 {
     backgroundList.Remove(thisComp);
 }