Exemple #1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        var player = collision.collider.gameObject.GetComponent <Player>();

        if (player)
        {
            player.Lives--;
            player.RemoveHeart();
            if (player.Lives > 0)
            {
                player.Health = 0;
                SpawningManager.Spawn(player);
            }
            else
            {
                var manager = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>();
                manager.players.Remove(player);
                Destroy(player.gameObject);
                var alivePlayers = manager.players.Count;
                if (alivePlayers == 1)
                {
                    var alivePlayer = manager.players[0];
                    manager.EndGame(alivePlayer.data.playerIndex, alivePlayer.data.characterIndex, alivePlayer.VictoryChant);
                }
            }
        }
    }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        gameManager    = (GameManager)FindObjectOfType(typeof(GameManager));
        weatherManager = (WeatherManager)FindObjectOfType(typeof(WeatherManager));
        entityManager  = (EntityManager)FindObjectOfType(typeof(EntityManager));
        spawnManager   = (SpawningManager)FindObjectOfType(typeof(SpawningManager));

        LoadDecisionTrees();
    }
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(this.gameObject);
     }
     Instance       = this;
     ObjectsToSpawn = new List <GameObject>()
     {
         turret,
         turret
     };
 }
Exemple #4
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance    = this;
         enemySpawns = new List <EnemySpawn>(SpawnersParent.GetComponentsInChildren <EnemySpawn>());
     }
     else
     {
         GameObject.Destroy(this.gameObject);
     }
     timeCounter = 0;
 }
Exemple #5
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        boolBetweenObjects = false;
    }
Exemple #6
0
    private void spawnPlayer(GameObject whereToSpawn)
    {
        //disabling HealthBar
        if (healthBar != null)
        {
            healthBar.SetActive(false);
        }

        //getting SpawnManager
        spawnManager = whereToSpawn.GetComponent <SpawningManager> ();
        //spawnManager.resetMPool (maxBulletAmmount, gameObject.GetComponent<NetworkIdentity>().connectionToServer);

        //spawning
        int randomNumber = (int)(Random.value * spawnManager.availableSpawns.Count);

        planet = whereToSpawn.transform;
        SpawningInfo spInfo = spawnManager.availableSpawns [randomNumber];

        ownTransform.position = spInfo.trans.TransformPoint(spInfo.position);
        alignToPlanet();
        ownTransform.position += (ownTransform.up * 50);


        //setting camera up
        GameObject cameraObj = GameObject.FindGameObjectWithTag("MainCamera");

        cameraTransform = cameraObj.transform;

        var CCA = CameraControlAdva.instance;

        CCA.rotationToChange = this;
        CCA.planetView       = false;
        CCA.changeFollow(ownTransform.gameObject);
        //CCA.invert = false;
        CCA.yOffset = 1.2f;
        CCA.toggleViewType(CameraControlAdva.ViewMode.around);
        CCA.targetOrientation = true;
//		CCA.cursorCheck ();

        //CmdChangeContinent(CustomNMUI.instance.continent);
        SmoothLookAtC slac = cameraObj.GetComponent <SmoothLookAtC> ();

        slac.target         = ownTransform;
        slac.useOtherOrient = true;
    }
Exemple #7
0
    // Start is called before the first frame update
    private void Awake()
    {
        instance = this;

        spawnPoints = new SpawnPoint[transform.childCount];
        rnd         = new System.Random();


        int i = 0;

        foreach (Transform spawnLocation in transform)
        {
            SpawnPoint s = new SpawnPoint();
            s.transform    = spawnLocation;
            spawnPoints[i] = s;
            i++;
        }
    }
    //void Awake(){
    //	instance = this;
    //}

    //public ObjectPlacer objTest;
    //private int awayLOD;
    void Start()
    {
        //seed = (int)System.DateTime.Now.Ticks;
        //awayLOD = LOD;
        falloffMap = FallOffGenerator.GenerateFalloffMap(textQual);
        if (player != null)
        {
            distThread = new TerrainUpdater();
        }
        //QualitySettings.shadowDistance = radius;
        for (int i = 0; i < lodLevel.Length; i++)
        {
            lodLevel [i].distance *= radius;
        }
        if (psh == null)
        {
            psh = gameObject.GetComponent <SpawningManager> ();
        }

        GenerateMap(true);
//		if (placeOnStart)
//			createTrees ();
    }
Exemple #9
0
 public void setSpawningManager(SpawningManager val)
 {
     spawningManager = val;
 }
Exemple #10
0
 void Start()
 {
     enemyManager    = GetComponent <EnemyManager>();
     fruitManager    = GetComponent <FruitsManager>();
     spawningManager = GetComponent <SpawningManager>();
 }
    void createNewChildren(/*bool putTrees*/)
    {
        //float interval2 = radius / planetInfo.squareSectionAmmount;
        MeshRenderer mr;

        //Generate the noise for all of the terrain
        for (int i = 0; i < planetInfo.chunksAmmount; i++)
        {
            Vector3 xyz = planetInfo.calculateXYZ(i);
//			float xDisp = -radius + interval2 + (interval2 * 2 * xyz.x);
//			float yDisp = -radius + interval2 + (interval2 * 2 * xyz.y);

            planetInfo.nmArray[i] = Noise.GenerateNoiseMap(textQual, textQual, seed, noiseScale, octaves, persistance, lacunarity, getOffset(xyz), Noise.NormalizeMode.Global);

            GameObject gO = new GameObject();
            planetInfo.chunkArray [i]   = gO.transform;
            planetInfo.chunkObject [i]  = gO;
            gO.transform.parent         = gameObject.transform;
            gO.transform.localPosition  = new Vector3(0, 0, 0);
            planetInfo.mfChunkArray [i] = gO.AddComponent(typeof(MeshFilter)) as MeshFilter;
            //MeshCollider mc = gO.AddComponent (typeof(MeshCollider)) as MeshCollider;
            //mc.enabled = false;
            //mc.convex = true;
            //if(pMaterial)mc.sharedMaterial = pMaterial;
            planetInfo.lodIdentifier [i] = LOD;
            //planetInfo.chunkObject [i].AddComponent<PlanetChunkID> ().chunkID = i;
            gO.transform.localEulerAngles  = getAngle((int)xyz.z);
            planetInfo.mcArray[i]          = gO.AddComponent <MeshCollider>();
            planetInfo.mcArray [i].enabled = false;
        }
        //Fixing the terrain to concadenate well with eachother
//		for (int i = 0; i < planetInfo.chunksAmmount; i++) {
//			Vector3 xyz = planetInfo.calculateXYZ (i);
//			float xDisp = -radius + interval2 + (interval2 * 2 * xyz.x);
//			float yDisp = -radius + interval2 + (interval2 * 2 * xyz.y);
//			//fixTerrain ();
//		}
        // Material and Color
        for (int i = 0; i < planetInfo.chunksAmmount; i++)
        {
            planetInfo.colorArray[i] = generateColorAndFalloff(planetInfo.nmArray[i], textQual, useFalloff, false);
            Texture2D texture = new Texture2D(textQual, textQual);
            texture.filterMode = FilterMode.Point;
            texture.wrapMode   = TextureWrapMode.Clamp;
            texture.SetPixels(planetInfo.colorArray [i]);
            texture.anisoLevel = 9;
            texture.Apply();
            mr = planetInfo.chunkObject[i].AddComponent(typeof(MeshRenderer)) as MeshRenderer;
            mr.sharedMaterial                = new Material(Shader.Find("Diffuse"));
            mr.sharedMaterial.mainTexture    = texture;
            planetInfo.chunkObject [i].layer = gameObject.layer;
            planetInfo.chunkObject [i].name  = (gameObject.name + "_" + i.ToString());
        }
        if (waterPrefab)
        {
            GameObject water = GameObject.Instantiate(waterPrefab);
            water.transform.parent        = gameObject.transform;
            water.transform.localPosition = Vector3.zero;
            float scale = radius * waterHeight;
            water.transform.localScale = new Vector3(scale, scale, scale);
        }
        //Create the mesh and show the terrain
        if (psh == null)
        {
            var localGO = gameObject.GetComponent <SpawningManager>();
            if (localGO != null)
            {
                psh = localGO;
            }
        }

        if (objPlacerObj != null)
        {
            for (int i = 0; i < planetInfo.chunksAmmount; i++)
            {
                ObjectPlacer tp1 = planetInfo.chunkObject [i].AddComponent(typeof(ObjectPlacer)) as ObjectPlacer;
                objPlacerObj.copyTo(tp1);

                tp1.calculateObjectID();
            }
        }

        StartCoroutine(updateAllMeshesCoroutine());
        //This is where the making of the mesh and making of trees was done now it was moved to a
        // coroutine for immediate seeing of the meshes and possibly a more responsive UI


        //DebugConsole.Log ("AvailableSpawnPositions: " + psh.availableSpawns.Count.ToString (), "normal");
    }