Inheritance: MonoBehaviour
Esempio n. 1
0
 public override void Trigger(DeathScript death)
 {
     if (GameObject.FindWithTag("GameController").GetComponent <GlobalTimer>().danger)
     {
         death.KillPlayer();
     }
 }
Esempio n. 2
0
    /* Damage - Inflicts damage and check if the object should be destroyed */
    public void Damage(float damageCount)
    {
        if(hp > 0) {
            // Object is alive
            hp -= damageCount;

            // Spawn -hp bubble
            var hpBubble = Instantiate(HPBubble) as Transform;
            hpBubble.transform.parent = transform;	// Make the current character its' parent

            // Set type of attack
            var hpBubbleScript = hpBubble.GetComponent<hpBubbleScript>();
            hpBubbleScript.dmgType = dmgTypes.Damage;
            hpBubbleScript.amount = damageCount;
        }
        else {
            // Object is dead
            deathScript = GetComponent<DeathScript>();
            if(deathScript) {
                deathScript.enabled = true;	// Deathscript is disabled by default, enabling it triggers deathstuff
                this.enabled = false;
            } else {
                // Object doesn't have a deathScript so just destroy it
                GameObject.Destroy(gameObject);
            }

        }
    }
    // Use this for initialization
    void Start()
    {
        AVtrap = false;
        active = false;
        buzzer = GameObject.FindWithTag("Buzzer").GetComponent <AudioSource>();

        switch (tileType)
        {
        case TrapType.Audio:
            AVtrap = true;
            trap   = audioTrap;
            break;

        case TrapType.Visual:
            AVtrap = true;
            trap   = visualTrap;
            break;

        case TrapType.Timed:
            trap = new TimedTrap();
            break;

        case TrapType.Death:
            trap = new DeathTrap();
            break;

        default:
            trap = null;
            break;
        }

        death = GameObject.FindGameObjectWithTag("DeathScript").GetComponent <DeathScript>();
    }
Esempio n. 4
0
 // Start is called before the first frame update
 void Start()
 {
     deathScript = playerThings.GetComponent <DeathScript>();
     velocity    = 0.0f;
     width       = GetComponent <BoxCollider2D>().bounds.size.x;
     height      = GetComponent <BoxCollider2D>().bounds.size.y;
 }
Esempio n. 5
0
 // Start is called before the first frame update
 void Start()
 {
     deathScript                = playBoth.GetComponent <DeathScript>();
     checkpointScript           = Checkpoint.GetComponent <CheckpointScript>();
     lineRenderer               = GetComponent <LineRenderer>();
     lineRenderer.enabled       = true;
     lineRenderer.useWorldSpace = true;
     on         = false;
     changing   = false;
     changeTime = 0 + delay;
     //Debug.Log("The starting change time is: " + changeTime);
     col         = GetComponent <BoxCollider2D>();
     changeOn    = false;
     changeOff   = false;
     damageTime  = 0f;
     timer       = 0f;
     changeTimer = 0;
     if (holdTime < 2)
     {
         holdTime = 2;
     }
     if (offTime < 2)
     {
         offTime = 2f;
     }
     lineRenderer.enabled = false;
 }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        //setup spider list
        spiders = new List <GameObject>();

        //setup the player
        playerController = fighter.GetComponent <PlayerController>();
        playerController.SetArsenal("Rifle");
        deathScript = fighter.GetComponent <DeathScript>();


        //get the bounds for the playing field
        Renderer mesh = this.GetComponent <Renderer>();

        maxHeight = mesh.bounds.max.z - margin;
        minHeight = mesh.bounds.min.z + margin;
        maxWidth  = mesh.bounds.max.x - margin;
        minWidth  = mesh.bounds.min.x + margin;

        playerHealth      = this.GetComponentInChildren <Text>();
        playerHealth.text = "Health: 100%";

        //vuforia setup
        trackableHandler = this.GetComponent <DefaultTrackableEventHandler>();
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        //if (other.CompareTag("Enemy"))
        //{

        //	GameObject myDeathObj = Instantiate(deathObj, transform.position, transform.rotation);
        //	DeathScript myScript = myDeathObj.GetComponent<DeathScript>();

        //	myScript.deathAudio = collideDeathAudio;

        //	Destroy(gameObject);
        //}

        if (other.CompareTag("Death Area Tag"))
        {
            GameObject  myDeathObj = Instantiate(deathObj, transform.position, transform.rotation);
            DeathScript myScript   = myDeathObj.GetComponent <DeathScript>();

            myScript.deathAudio = fallDeathAudio;

            mainManager.PlayerDeath();

            Destroy(gameObject);
            //StartCoroutine(DelayedRespawn(2f));
        }
    }
Esempio n. 8
0
	void Start () {
		cameraMoveScript = Cam.GetComponent<CameraMoveScript> ();
		deathScript = Turtle.GetComponent<DeathScript> ();
		rotatesemi = Turtle.GetComponent<rotateSemi> ();
		setsortingLayer = ShaderCube.GetComponent<setSortingLayer> ();
		turtleMovementScript = Turtle.GetComponent<TurtleMovementScript> ();
	}
Esempio n. 9
0
 // Start is called before the first frame update
 void Start()
 {
     Zombies     = new List <GameObject>();
     deathScript = GetComponent <DeathScript>() as DeathScript;
     Random.InitState((int)System.DateTime.Now.Ticks);
     audioSource = GetComponent <AudioSource>();
 }
Esempio n. 10
0
 void Start()
 {
     player         = GameObject.FindGameObjectWithTag("Player");
     origoPosition  = transform.position;
     rBody2d        = GetComponent <Rigidbody2D>();
     deathScript    = GetComponent <DeathScript>();
     targetLocation = RandomVector2D() + (Vector2)transform.position;
 }
Esempio n. 11
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         DeathScript deathscript = other.gameObject.GetComponent <DeathScript>() as DeathScript;
         deathscript.SetCheckpoint(checkpointSpawn);
     }
 }
Esempio n. 12
0
 void Start()
 {
     cameraMoveScript     = Cam.GetComponent <CameraMoveScript> ();
     deathScript          = Turtle.GetComponent <DeathScript> ();
     rotatesemi           = Turtle.GetComponent <rotateSemi> ();
     setsortingLayer      = ShaderCube.GetComponent <setSortingLayer> ();
     turtleMovementScript = Turtle.GetComponent <TurtleMovementScript> ();
 }
Esempio n. 13
0
 public void OnMouseUp()
 {
     StartCoroutine(DeathScript.Reset(false));
     if (gameObject.name == "try again")
     {
         DeathScript.ResetDeaths();
     }
 }
Esempio n. 14
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         PlayerPrefs.SetString("lastLoadedScene", SceneManager.GetActiveScene().name);
         DeathScript.DestroyPlayer();
         onExit.Invoke();
     }
 }
Esempio n. 15
0
    DeathScript deathScript; // When health is 0, trigger this script

    private void Start()
    {
        // Set to max health
        health       = maxHealth;
        visualHealth = health;

        audioManager = PlayerController.playerAudioManager;
        deathScript  = GameObject.FindObjectOfType <DeathScript>(); // Script for when the player dies
    }
Esempio n. 16
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         PlayerPrefs.SetString("lastLoadedScene", SceneManager.GetActiveScene().name);
         DeathScript.DestroyPlayer();
         GetComponent <Animator>().SetTrigger("Jump");
         Camera.main.GetComponent <CameraFollowScript>().follow = gameObject;
     }
 }
Esempio n. 17
0
 void OnTriggerStay2D(Collider2D col)
 {
     if (on && (col.gameObject.name.Equals("Player") || col.gameObject.name.Equals("Player2")))
     {
         if (deathScript == null)
         {
             deathScript = playBoth.GetComponent <DeathScript>();
         }
         deathScript.dead = true;
     }
 }
Esempio n. 18
0
    void goBack()
    {
        if (gameObject.name == "backtomenu")
        {
            DeathScript.ResetDeaths();
        }

        infoPanel = GameObject.Find("infoui(Clone)");

        SceneManager.LoadScene("LvlPack" + (currentPack + 1).ToString());
    }
Esempio n. 19
0
 void GameEnded()
 {
     ac.PlayGoal();
     SceneController.LoadEndingBox();
     SceneEnded();
     AnimationPlay(false);
     GetComponent <DeathScript>().enabled = false;
     TimeCounter.ToggleTimerActive(false);
     this.enabled = false;
     EndGameVariables.UpdateCurrentNumbers(timeC.timeInSec - 1, DeathScript.GetDeaths());
 }
Esempio n. 20
0
    // Start is called before the first frame update
    void Start()
    {
        /*
         * if (em == null)
         * {
         *  em = FindObjectOfType<EventManager>().GetComponent<EventManager>();
         * }
         */

        //deathScript = playBoth.GetComponent<DeathScript>();
        //checkpointScript = Checkpoint.GetComponent<CheckpointScript>();
        deathScript = playerThings.GetComponent <DeathScript>();
    }
Esempio n. 21
0
    void OnCollisionEnter(Collision collision)
    {
        Collider col = collision.collider;

        Debug.Log("Collision detected between " + gameObject.name + " and " + col.name);

        DeathScript ds = col.gameObject.GetComponent <DeathScript> ();

        if (ds != null)
        {
            ds.Kill();
        }
    }
Esempio n. 22
0
 public void checkWin()
 {
     if (!DeathScript.player)
     {
         return;
     }
     if (enemyNB > 0)
     {
         return;
     }
     MenuManagerScript.mm.setMissionCompleteMenu(true);
     DeathScript.playSound(winSound);
     DeathScript.DestroyPlayer();
     enemyNB = -1;
 }
Esempio n. 23
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         DeathScript deathscript = other.gameObject.GetComponent <DeathScript>() as DeathScript;
         deathscript.ResetPlayer();
     }
     else if (other.gameObject.tag == "zombie")
     {
         ZombieController zombiScript = other.gameObject.GetComponent <ZombieController>() as ZombieController;
         zombiScript.KillZombie();
     }
     else if (other.gameObject.tag == "ball")
     {
         BallOfForce ball = other.gameObject.GetComponent <BallOfForce>() as BallOfForce;
         ball.DestroyBall();
     }
 }
Esempio n. 24
0
    void UpdateTimer()
    {
        timeText.text = ConvertSecsToString(timeInSec);

        if (countDown)
        {
            timeInSec--;
        }

        else
        {
            timeInSec++;
        }

        if (countDown && timeInSec == 9)
        {
            watch.color    = Color.red;
            timeText.color = Color.red;
            ChangeToColor(red);
        }

        if (countDown && timeInSec < 0)
        {
            timerActive = false;
            GPlayclass.UnlockAchievement("CgkI-Meyi84DEAIQCA");
            StartCoroutine(DeathScript.Reset(false));
        }

        if (timeInSec > 3599)
        {
            StartCoroutine(DeathScript.Reset(false));
        }

        if (timeInSec == 180)
        {
            GPlayclass.UpdateEvent("CgkI-Meyi84DEAIQCQ", 1);
        }

        else if (timeInSec == 360)
        {
            GPlayclass.UpdateEvent("CgkI-Meyi84DEAIQCQ", 2);
        }
    }
Esempio n. 25
0
    public void OnMouseUp()
    {
        if (pack == "Pack 1")
        {
            SceneManager.LoadScene(n);
        }

        else if (pack == "Pack 2")
        {
            SceneManager.LoadScene(n + lvlCount * 1);
        }

        else if (pack == "Pack 3")
        {
            SceneManager.LoadScene(n + lvlCount * 2);
        }

        DeathScript.ResetDeaths();
    }
Esempio n. 26
0
    private bool HierarchyIsDead(Transform hierarchy)
    {
        DeathScript ds = hierarchy.GetComponent <DeathScript> ();

        if (ds != null && !ds.IsDead())
        {
            return(false);
        }
        else
        {
            foreach (Transform child in hierarchy)
            {
                if (!HierarchyIsDead(child))
                {
                    return(false);
                }
            }
            return(true);
        }
    }
Esempio n. 27
0
    private float m_fStartHeight;    // snipers starting height

    // Use this for initialization
    void Awake()
    {
        m_ReticleMain  = Instantiate <GameObject>(m_ReticleMainPrefab);
        m_ReticleTop   = m_ReticleMain.transform.Find("RetTop").gameObject;
        m_ReticleBot   = m_ReticleMain.transform.Find("RetBot").gameObject;
        m_ReticleLeft  = m_ReticleMain.transform.Find("RetLeft").gameObject;
        m_ReticleRight = m_ReticleMain.transform.Find("RetRight").gameObject;

        m_ReticleTopStart   = m_ReticleTop.transform.localPosition;
        m_ReticleBotStart   = m_ReticleBot.transform.localPosition;
        m_ReticleLeftStart  = m_ReticleLeft.transform.localPosition;
        m_ReticleRightStart = m_ReticleRight.transform.localPosition;
        m_SniperRB          = gameObject.GetComponent <Rigidbody>();

        m_PrevPos = transform.position;

        m_PlayerRB = m_Player.GetComponent <Rigidbody>();
        m_Death    = GetComponent <DeathScript>();
        m_Death.m_RelatedObjects.Add(m_ReticleMain);

        m_fStartHeight = transform.position.y;
    }
Esempio n. 28
0
    protected override void Setup()
    {
        // IF Player has not been set
        if (!m_Player)
        {
            m_Player = GameObject.FindGameObjectWithTag("Player");
        }

        if (!m_Death)
        {
            m_Death = GetComponent <DeathScript>();
        }

        // IF always chase is true
        if (m_bAlwaysChase)
        {
            // Set chase range to max float value
            m_fChaseRange = float.MaxValue;
        }

        // Perform Base Setup
        base.Setup();
    }
Esempio n. 29
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.CompareTag("GROUND"))
        {
            if (myState == PlayerState.Swinging)
            {
                UnHook();
            }

            myState = PlayerState.Running;
        }

        if (other.gameObject.CompareTag("Enemy"))
        {
            GameObject  myDeathObj = Instantiate(deathObj, transform.position, transform.rotation);
            DeathScript myScript   = myDeathObj.GetComponent <DeathScript>();

            myScript.deathAudio = collideDeathAudio;

            mainManager.PlayerDeath();

            Destroy(gameObject);
        }
    }
Esempio n. 30
0
    private Vector3 offset;         //Private variable to store the offset distance between the player and camera

    // Use this for initialization
    void Start()
    {
        gameManagement   = GameObject.Find("EndOfLevel").GetComponent <GameManagementScript>();
        horScript        = player.GetComponent <HorizontalMovement>();
        firstEnd         = horScript.firstEnd;
        onInit           = true;
        startDead        = true;
        deathScript      = playBoth.GetComponent <DeathScript>();
        firstStopScript  = firstStop.GetComponent <cameraEnd>();
        secondStopScript = secondStop.GetComponent <cameraEnd>();
        //Calculate and store the offset value by getting the distance between the player's position and camera's position.
        offset = transform.position - player.transform.position;
        cam    = GetComponent <Camera>();
        //the screen position of the two player characters
        playerCam  = cam.WorldToScreenPoint(player.transform.position);
        player2Cam = cam.WorldToScreenPoint(player2.transform.position);
        playerAvg  = (playerCam.x + player2Cam.x) / 2;
        //the screen height
        height             = cam.pixelHeight;
        width              = cam.pixelWidth;
        p1width            = player.GetComponent <BoxCollider2D>().bounds.size.x;
        initCam            = (cam.ScreenToWorldPoint(new Vector3(playerAvg + width / 2, height / 2)));
        initCam           -= new Vector3(p1width * 3 / 4, 0);
        transform.position = initCam;
        camLeft            = new Vector3(0, 0, 0);
        camRight           = new Vector3(0, 0, 0);
        camLeft            = cam.ScreenToWorldPoint(transform.position);
        Vector3 widThing = new Vector3(width, 0, 0);

        widThing       = cam.ScreenToWorldPoint(widThing);
        camRight       = transform.position + widThing;
        curCamEnd      = firstStopScript.cameraHere;
        switchStop     = false;
        freezePlayers  = false;
        switchToSecond = false;
    }
Esempio n. 31
0
 void Start()
 {
     deathScript = GetComponentInParent <DeathScript>();
 }
Esempio n. 32
0
 void Start()
 {
     deathScript = transform.root.GetComponentInChildren<DeathScript>();
     actions.Add(Grounded);
 }
 public override void Trigger(DeathScript death)
 {
     death.KillPlayer();
 }
Esempio n. 34
0
 void Start()
 {
     fireATS = FindObjectOfType(typeof(FireAttackScript)) as FireAttackScript;
     deathScript = transform.root.GetComponentInChildren<DeathScript>();
 }