Inheritance: MonoBehaviour
 void Awake()
 {
     fireArrival = 0;
     player = GameObject.FindGameObjectWithTag(TagManager.PLAYER);
     respawn = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<Respawn>();
     gameMenu = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<GameMenu>();
 }
Beispiel #2
0
 void Awake()
 {
     wasPlayed = false;
     player = GameObject.FindGameObjectWithTag(TagManager.PLAYER);
     respawn = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<Respawn>();
     gameMenu = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<GameMenu>();
 }
Beispiel #3
0
 void Start()
 {
     spikeSpawn = FindObjectOfType<SpikeSpawn>();
     respawn = FindObjectOfType<Respawn> ();
     currentHealth = maxHealth;
     InvokeRepeating("decreseHealth", 1f, 1f);
 }
	public override void Start () 
	{
		GameObject respawnPoint = GameObject.FindGameObjectWithTag("Respawn");
		respawn = respawnPoint.GetComponent<Respawn> ();
		base.Start ();
		collisions.facingDir = 1;
	}
Beispiel #5
0
	void Awake ()
	{
		_spriteRenderers = GetComponentsInChildren<SpriteRenderer> ();
		_rigidbody2D = GetComponent<Rigidbody2D> ();
		_transform = transform;
		_respawn = GetComponent<Respawn> ();
		_movement = GetComponent<BasicPlayerMovementScript> ();
	}
Beispiel #6
0
    public void Setup()
    {
        movement = instance.GetComponent <Movement>();
        shooting = instance.GetComponent <Shoot>();
        respawn  = instance.GetComponent <Respawn>();

        movement.playerNum = playerNum;
        shooting.playerNum = playerNum;
        respawn.spawnPoint = spawnPoint;
    }
Beispiel #7
0
    void Start()
    {
        respawn = GetComponent <Respawn>();
        MovementStart();
        backWheel.ConfigureVehicleSubsteps(1, 12, 15);
        frontWheel.ConfigureVehicleSubsteps(1, 12, 15);

        rb.centerOfMass = centerOfMass;
        IdleMode        = true;
    }
        private static IEnumerator RespawnCoroutine(Respawn respawn)
        {
            float timePassed = (float)DayNightCycle.main.timePassed;
            float waitTime   = (float)System.Math.Round(respawn.spawnTime - timePassed);

            yield return(new WaitForSecondsRealtime(waitTime));

            respawn.Spawn();
            UnityEngine.Object.Destroy(respawn.gameObject);
        }
    void Start()
    {
        respawn = GameObject.FindWithTag("Player").GetComponent <Respawn>();

        deathScore = GameObject.FindWithTag("ScoreText").GetComponent <TMPro.TextMeshProUGUI>();

        odometer = GameObject.FindWithTag("ScoreCanvas").GetComponent <Odometer>();

        PlayerPrefs.SetFloat("HighScore", 0f);
    }
Beispiel #10
0
    public void Damage(int damageCount)
    {
        hp -= damageCount;

        if (hp <= 0)
        {
            Respawn res = gameObject.GetComponent <Respawn>();
            res.dead();
        }
    }
Beispiel #11
0
    private void Start()
    {
        characterController = GetComponent <CharacterController>();
        respawn             = GetComponent <Respawn>();
        pauseCanvas.enabled = false;
        Time.timeScale      = 1.0f;
        isLoading           = false;

        Cursor.visible = false;
    }
Beispiel #12
0
    private void RespawnAllCars()
    {
        for (int carIndex = 0; carIndex < popSize; carIndex++)
        {
            GameObject      carS = carSpecies[carIndex];
            Respawn         r    = carS.GetComponent <Respawn>();
            Car2DController c2Dc = carS.GetComponent <Car2DController>();
            //float distanceFitness = Mathf.Pow(1.1f, c2Dc.TravelledDistance) + Mathf.Pow(1.1f, Vector2.Distance(rbCar[carIndex].position, r.respawnPoint.position));
            float distanceFitness = c2Dc.TravelledDistance + Vector2.Distance(rbCar[carIndex].position, r.respawnPoint.position);
            population.Members[carIndex].Fitness += distanceFitness;
            if (!r.isAlive && level.penalizeDeath)
            {
                //double timeFactor = c2Dc.TimeAlive / (1.05 * level.MaxTime);
                //population.Members[carIndex].Fitness *= timeFactor;

                //double timeFactor = Functions.Map(c2Dc.TimeAlive, 0, level.MaxTime, 0.9, 0.95);
                //population.Members[carIndex].Fitness *= timeFactor;

                //double linearCoefficientOfTime = Functions.Line(c2Dc.TimeAlive, 10.0 / level.MaxTime, -5.0);
                //double constraintlinearCoefficientOfTime = Functions.Logistic(linearCoefficientOfTime);
                //population.Members[carIndex].Fitness *= constraintlinearCoefficientOfTime;

                population.Members[carIndex].Fitness *= TimeEffectWithRespectToCurrentGeneration(c2Dc.TimeAlive, population.CurrentGeneration, level.MaxTime, level.thresholdGeneration, level.timeMattersAtTheBeginning, level.lessTimeIsBetter);  //Currently works!

                //double sensorCoefficient = 1 / c2Dc.CumulativeSensoryData;
            }
            //Debug.Log(population.Members[carIndex].Fitness + " of car #" + carIndex.ToString());
            carS.GetComponent <SpriteRenderer>().color = new Color32(255, 255, 255, 255);
            r.RespawnCar();
        }
        bestCar.GetComponent <Respawn>().RespawnCar();
        bestCar.GetComponent <SpriteRenderer>().color = new Color32(0, 255, 0, 255);
        carsHaveRespawned = true;
        population.SortSpeciesByFitness();
        population.NormalizeFitness();
        population.FilterByPerformance();
        double bestFitness = population.ToBreed();       // make mutation rate dynamic

        guiManager.startTime        = Time.time;
        guiManager.numOfGenerations = population.CurrentGeneration;
        guiManager.bestFitness      = bestFitness;
        elapsedTime = 0.0f;
        AssignBrains();

        //Every 50 generation saves progress
        if (level.ToggleFileIO)
        {
            if (population.CurrentGeneration % 50 == 0)
            {
                SaveBestBrain("bestBrain.txt", population.BestMember);
                SavePopulationToFile("population.bin");
            }
            Debug.Log(bestFitness);
        }
    }
Beispiel #13
0
 void Awake()
 {
     respawn = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<Respawn>();
     dying = false;
     respawning = false;
     currentColor = Color.black;
     screenRect = new Rect(0f, 0f, Screen.width, Screen.height);
     player = GameObject.FindGameObjectWithTag(TagManager.PLAYER);
     money = player.GetComponent<MoneyManagement>();
     loadGame = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<LoadGameSettings>();
 }
Beispiel #14
0
 public void Reset()
 {
     Level.Rotation = Vector3.Zero;
     Translation    = Level.GetNode <Spatial>("SpawnPoint").GlobalTransform.origin;
     ShouldKill     = false;
     velocity       = Vector3.Zero;
     Respawn?.Invoke();
     RotationDir = 1;
     Visible     = true;
     CalibrateCamera?.Invoke();
 }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        Respawn respawnScript = (Respawn)target;

        if (GUILayout.Button("Respawn player"))
        {
            respawnScript.RespawnPlayer();
        }
    }
Beispiel #16
0
 void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.tag == "Bala")
     {
         vidaE -= bala;
         if (vidaE <= 0)
         {
             Freno();
             Destroy(gameObject, 4f);
             if (spa == 1)
             {
                 spa = 0;
                 fueg.SetActive(true);
                 yorb.isKinematic = true;
                 SpawnCenter discon = GameObject.FindGameObjectWithTag("Spawn").GetComponent <SpawnCenter> ();
                 discon.enmMax  += 1;
                 discon.enmRest -= 1;
                 GameObject.FindGameObjectWithTag("Spawn").SendMessage("Spawn");
                 Respawn ben = GameObject.FindGameObjectWithTag("Spawn").GetComponent <Respawn> ();
                 ben.puntaje += beneficio;
                 GameObject.FindGameObjectWithTag("Spawn").SendMessage("Puntos");
             }
         }
     }
     else if (other.gameObject.tag == "Player")
     {
     }
     else if (other.gameObject.tag == "Explosivo" || other.gameObject.tag == "ExploEnm")
     {
         vidaE -= explo;
         if (vidaE <= 0)
         {
             Freno();
             Destroy(gameObject, 4f);
             if (spa == 1)
             {
                 spa = 0;
                 fueg.SetActive(true);
                 yorb.isKinematic = true;
                 SpawnCenter discon = GameObject.FindGameObjectWithTag("Spawn").GetComponent <SpawnCenter> ();
                 discon.enmMax  += 1;
                 discon.enmRest -= 1;
                 GameObject.FindGameObjectWithTag("Spawn").SendMessage("Spawn");
                 Respawn ben = GameObject.FindGameObjectWithTag("Spawn").GetComponent <Respawn> ();
                 ben.puntaje += beneficio;
                 GameObject.FindGameObjectWithTag("Spawn").SendMessage("Puntos");
             }
         }
     }
     else
     {
         ranDireccion();
     }
 }
Beispiel #17
0
    private void Start()
    {
        instance = this;

        if (isLocalPlayer)
        {
            spawnPoints = FindObjectsOfType <NetworkStartPosition>();
        }

        spawnPointIndex = Random.Range(0, spawnPoints.Length - 1);
    }
Beispiel #18
0
 // Start is called before the first frame update
 void Start()
 {
     //Calls on the component RigidBody
     rb             = GetComponent <Rigidbody2D>();
     bc             = GetComponent <BoxCollider2D>();
     facingRight    = true;
     nextdashtime   = 0;
     AudioObj       = GameObject.FindObjectOfType <PlayerAudio>();
     RespawnObj     = GameObject.FindObjectOfType <Respawn>();
     EnemyHealthObj = GameObject.FindObjectOfType <EnemyHealth>();
 }
Beispiel #19
0
    void RespawnPlayer()
    {
        player.ResetPlayer();
        Respawn playerRespawn = player.GetComponent <Respawn>();

        if (playerRespawn)
        {
            playerRespawn.RespawnObject();
            Debug.Log("Respawning player!");
        }
    }
Beispiel #20
0
	void Start ()
	{
		controller = GetComponent<P2Controller2D>();
		GameObject respawnPoint = GameObject.FindGameObjectWithTag("Respawn");
		respawn = respawnPoint.GetComponent<Respawn> ();

		gravity = -(2 * JumpHeight) / Mathf.Pow (timeToJumpApex, 2);
		jumpVelocity = Mathf.Abs (gravity) * timeToJumpApex;
		
		gameObject.name = "Player2";
	}
Beispiel #21
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        //if (other.tag == "Player") {
        //Destroy(other.gameObject);
        //}
//		Respawn.respawn();
        Transform respTrasform = FindObjectOfType <Respawn>().transform;

//		other.gameObject.transform.position = respTrasform.position;
        Respawn.respawn(other.gameObject.transform, respTrasform);
    }
Beispiel #22
0
 private void Start()
 {
     playerS     = FindObjectOfType <PlayerMove>();
     player      = GameObject.FindGameObjectWithTag("Player").transform;
     anim        = GetComponent <Animator>();
     nav         = GetComponent <NavMeshAgent>();
     resetEnemys = FindObjectOfType <Respawn>();
     Ndis        = GameObject.Find("Ndistancia").GetComponent <Text>();
     colliderS   = GetComponent <SphereCollider>();
     numEnemigos = FindObjectOfType <SpawnEnemigos>();
 }
Beispiel #23
0
    void Start()
    {
        if (!(respawn = GetComponent <Respawn>()))
        {
            Debug.LogError("Unable to set up respawn script");
        }

        if (!(health = GetComponent <Health>()))
        {
            Debug.LogError("Unable to get health script");
        }
    }
        internal static void PostFix(Respawn __instance)
        {
            if (DayNightCycle.main.timePassed >= (double)__instance.spawnTime) // if this is true respawn would have already happened in method
            {
                return;
            }

            if (Settings.instance.leviathansRespawn && !__instance.techType.IsLeviathan())
            {
                CoroutineHost.StartCoroutine(RespawnCoroutine(__instance));
            }
        }
Beispiel #25
0
    // Start is called before the first frame update
    void Start()
    {
        myRb           = GetComponent <Rigidbody>();
        myController   = GetComponent <AdvancedWalkerController>();
        myCollider     = GetComponent <CapsuleCollider>();
        myRespawnPoint = GetComponent <Respawn>();



        myCollider.height = 1.5f;
        myCollider.center = centerCaps;
    }
Beispiel #26
0
        void ResetPlayerPosition()
        {
            float   x     = (game.World.Width / 2) + 0.5f;
            float   z     = (game.World.Length / 2) + 0.5f;
            Vector3 spawn = Respawn.FindSpawnPosition(game, x, z, game.LocalPlayer.Size);

            LocationUpdate update = LocationUpdate.MakePosAndOri(spawn, 0, 0, false);

            game.LocalPlayer.SetLocation(update, false);
            game.LocalPlayer.Spawn = spawn;
            game.CurrentCameraPos  = game.Camera.GetPosition(0);
        }
Beispiel #27
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "ball")
     {
         scoresManager.UpdateScore(pad);
         Respawn ball = other.GetComponent <Respawn>();
         if (ball != null)
         {
             ball.ResetBall();
         }
     }
 }
Beispiel #28
0
        static void Prefix(Respawn __instance, ref bool ____canPress)
        {
            if (Main.enabled && Main.settings.respawnNearBail && ____canPress)
            {
                Coroutine doBailTmpCoroutine = __instance.GetExtensionComponent().DoBailTmpCoroutine;

                if (doBailTmpCoroutine != null)
                {
                    ((MonoBehaviour)PlayerController.Instance).StopCoroutine(doBailTmpCoroutine);
                }
            }
        }
Beispiel #29
0
    // Use this for initialization
    void Start()
    {
        respawn        = GetComponent <Respawn>();
        gameManager    = FindObjectOfType <GameManager>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        gameManager.addEnemy(this);

        StartCoroutine(Fire());

        defaultColor = spriteRenderer.material.color;
    }
Beispiel #30
0
    void InitialiseRespawn()
    {
        const int defaultRespawnNode = -1;

        respawn        = GetComponent <Respawn>();;
        waypointNodeID = defaultRespawnNode;
        respawn.AddLastToRespawnAction(() => { Go(0); });
        respawn.AddLastToRespawnAction(() => { Stop(breakForce); });
        respawn.AddLastToRespawnAction(pid.ResetValues);
        respawn.AddLastToRespawnAction(() => { respawn.respawnNode = waypointNodeID - 1; });
        respawn.AddLastToRespawnAction(() => { timeAlive = 0; StartCoroutine(SetIdleOnATimer(2f)); });
        respawn.AddLastToRespawnAction(() => { respawn.RespawnObject(GetNextWayPoint(0), (GetNextWayPoint(0 + 1) - GetNextWayPoint(0)).normalized); });
    }
Beispiel #31
0
    private void Start()
    {
        Respawn respawnScript = FindObjectOfType <Respawn>();

        if (respawnScript)
        {
            respawnScript.respawns.Add(this);
        }
        else
        {
            Destroy(this);
        }
    }
Beispiel #32
0
    // Start is called before the first frame update
    void Start()
    {
        player = GameObject.Find("Player");

        isGrounded = GetComponent <IsGrounded>();
        respawn    = player.GetComponent <Respawn>();
        progress   = player.GetComponent <Progress>();

        logger = GameObject.Find("Telemetry").GetComponent <Logger>();
        sfx    = GameObject.Find("SFX").GetComponent <SFXScript>();

        hud = GameObject.Find("HUD");
    }
Beispiel #33
0
 private void Start()
 {
     numEnemigos = FindObjectOfType <SpawnEnemigos>();
     playerS     = FindObjectOfType <PlayerMove>();
     player      = GameObject.FindGameObjectWithTag("Player").transform;
     anim        = GetComponent <Animator>();
     colliderS   = GetComponent <SphereCollider>();
     nav         = GetComponent <NavMeshAgent>();
     healthBar   = FindObjectOfType <HealthBar>();
     resetEnemys = FindObjectOfType <Respawn>();
     Nmele       = GameObject.Find("Nmele").GetComponent <Text>();
     aguaM       = FindObjectOfType <AguaMagica>();
 }
Beispiel #34
0
 private void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         SpriteRenderer sr = other.gameObject.GetComponent <SpriteRenderer>();
         if (sr.color != ColorsManager.Instance.colors[color])
         {
             Transform respTrasform = FindObjectOfType <Respawn>().transform;
             Respawn.respawn(other.gameObject.transform, respTrasform);
             //Debug.Log(color + " " + sr.color);
         }
     }
 }
Beispiel #35
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.name.Contains("Skater"))
     {
         Respawn r = PlayerController.Instance.respawn;
         // Break the pointer reference
         Vector3 playerOffset = r.getSpawn[0].position - r.getSpawn[1].position - new Vector3(0.0f, 0.08f, 0.0f);
         this._pinPos  = new Vector3(r.pin.position.x, r.pin.position.y, r.pin.position.z);
         this._pinQuat = new Quaternion(r.pin.rotation.x, r.pin.rotation.y, r.pin.rotation.z, r.pin.rotation.w);
         r.SetSpawnPos(this._destination.position - playerOffset, this._destination.rotation);
         r.DoRespawn();
         r.SetSpawnPos(this._pinPos - playerOffset, this._pinQuat);
     }
 }
Beispiel #36
0
 void Start()
 {
     SFX         = GetComponent <AudioSource> ();
     spawner     = GetComponent <Respawn> ();
     rb          = GetComponent <Rigidbody>();
     hp          = GetComponent <HealthHandler>();
     ray         = GetComponent <RayCast>();
     facingRight = true;
     facingLeft  = false;
     canMove     = true;
     //canJump = isGrounded();
     speed     = 10f + PlayerPrefs.GetInt("dex");
     wantsJump = false;
 }
 private void Update()
 {
     isRespawning = false;
     movement.z   = Input.GetAxis(Axes.Vertical) * forceSpeed.z;
     movement.x   = Input.GetAxis(Axes.Horizontal) * forceSpeed.x;
     if (Input.GetButton(Axes.Jump))
     {
         doJump = true;
     }
     if (Input.GetKeyDown(KeyCode.R))
     {
         Respawn.DoRespawn(respawn);
     }
 }
Beispiel #38
0
    private void findPlayers()
    {
        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
        if (players.Length > 0)
        {
            player1 = players[0].GetComponent<Respawn>();
            if (players.Length > 1)
                player2 = players[1].GetComponent<Respawn>();
            playersFound = true;
            return;
        }

        /*GameObject p = GameObject.FindGameObjectWithTag("Player");
        if (playersFound != null)
        {
            player1 = players[0].GetComponent<Respawn>();
            return;
        }*/
        Debug.Log("No GO with tag \"Player\"");
        playersFound = false;
    }
Beispiel #39
0
 public void Respawn(Respawn rpc)
 {
     hp = hpMax;
     SwitchWorld("Town");
 }