예제 #1
0
    private void OnGUI()
    {
        GUILayout.Label("Balance Manager", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        EditorGUILayout.HelpBox("Hover over the text of any item to get a brief description. Make sure to reset connections after debugging.", MessageType.Info);
        GUILayout.Label("Engine Scipt edits", EditorStyles.boldLabel);
        engine.engineCoolingAmount        = EditorGUILayout.Slider(new GUIContent("Cooling Speed", "This is the speed at which the engine will cool down."), engine.engineCoolingAmount, 0.1f, 10);
        engine.florpCoolingPercentage     = EditorGUILayout.Slider(new GUIContent("Florp Power", "Percentage of engine that is cooled when florp is inserted."), engine.florpCoolingPercentage, 0.1f, 1);
        engine.progressionMultiplier      = EditorGUILayout.Slider(new GUIContent("Progression Multiplier", "How fast the ship progression bar will move."), engine.progressionMultiplier, 0.1f, 2);
        engine.enemyProgressionMultiplier = EditorGUILayout.Slider(new GUIContent("Enemy Progression Multiplier", "How fast the enemy ship progression bar will move."), engine.enemyProgressionMultiplier, 0.1f, 2);

        GUILayout.Label("Ship Health Scipt edits", EditorStyles.boldLabel);
        shipHealth.timeBetweenNEvents    = EditorGUILayout.Slider(new GUIContent("Time Between Events", "Time between the blasts. Or the time between the events that will cause damage to the ship."), shipHealth.timeBetweenNEvents, 0.1f, 15);
        shipHealth.timeBeforeEventsStart = EditorGUILayout.Slider(new GUIContent("Time Before Event Starts", "Time between the blasts. Or the time between the events that will cause damage to the ship."), shipHealth.timeBeforeEventsStart, 0.1f, 15);
        GUILayout.Label("Fire Scipt edits", EditorStyles.boldLabel);
        grid.fireStartPercentage = EditorGUILayout.Slider(new GUIContent("Fire Start Percentage", "Time between the blasts. Or the time between the events that will cause damage to the ship."), grid.fireStartPercentage, 1, 100);
        grid.fireTimer           = EditorGUILayout.Slider(new GUIContent("Fire Spread timer", "Time between the blasts. Or the time between the events that will cause damage to the ship."), grid.fireTimer, 0.1f, 15);
        GUILayout.Space(25);
        if (GUILayout.Button("RESET CONNECTIONS"))
        {
            engine     = FindObjectOfType <Engine>();
            shipHealth = FindObjectOfType <ShipHealth>();
            grid       = FindObjectOfType <Grid>();
        }
    }
예제 #2
0
    public void WinGame()
    {
        rfs.StopDamageTimer();
        ShipHealth h = GetComponent <ShipHealth>();
        //Figure out clout change based on damage taken relative to max health
        float  percentDamage = h.Health / h.MaxHealth;
        int    damageBracket = RandomizerForStorms.GetBracket(damageLevelPercents, percentDamage);
        int    cloutGained   = Mathf.CeilToInt((survivalGain.y - survivalGain.x) * percentDamage + survivalGain.x);
        string cloutText     = damageLevelText[damageBracket] + "\n\n" + $"For making your way out of the storm with your ship intact, your clout has risen {Mathf.RoundToInt(cloutGained)}." +
                               $" Combined with the {cloutChange} from the ritual, your clout has changed a total of {Mathf.RoundToInt(cloutGained + cloutChange)}.";

        Globals.GameVars.AdjustPlayerClout(cloutGained + cloutChange, false);

        mgInfo.gameObject.SetActive(true);
        mgInfo.DisplayText(
            Globals.GameVars.stormTitles[3],
            Globals.GameVars.stormSubtitles[3],
            Globals.GameVars.stormSuccessText[0] + "\n\n" + cloutText + "\n\n" + Globals.GameVars.stormSuccessText[Random.Range(1, Globals.GameVars.stormSuccessText.Count)],
            stormIcon,
            MiniGameInfoScreen.MiniGame.Finish);
        finishButton.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = winFinishText;
        finishButton.onClick.RemoveAllListeners();
        finishButton.onClick.AddListener(UnloadMinigame);
        GetComponent <StormMGmovement>().ToggleMovement(false);
    }
예제 #3
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            if (isBoss)
            {
                ShipHealth playerHp = collision.GetComponent <ShipHealth>();

                if (!playerHp.getInvincibleStatus())
                {
                    collision.GetComponent <PlayerDamageable>().TakeDamage(damage);

                    spawnParticle();

                    Destroy(gameObject);
                }
            }
            else
            {
                collision.GetComponent <PlayerDamageable>().TakeDamage(damage);

                spawnParticle();

                Destroy(gameObject);
            }
        }
    }
예제 #4
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.tag.Equals("Player"))
        {
            // Find the ShipHealth script associated with the rigidbody.
            ShipHealth targetHealth = target.GetComponent <ShipHealth> ();

            // Calculate the amount of damage the target should take based on it's distance from the shell.

            // Move the instantiated explosion prefab to the Ship's position and turn it on.
            m_ExplosionParticles.transform.position = transform.position;
            m_ExplosionParticles.gameObject.SetActive(true);

            // Play the particle system of the Ship exploding.
            m_ExplosionParticles.Play();

            // Play the Ship explosion sound effect.
            m_ExplosionAudio.Play();

            // Deal this damage to the Ship.
            targetHealth.TakeDamage(damage);

            // Destroy(gameObject);
            gameObject.SetActive(false);
        }
    }
예제 #5
0
    // Start is called before the first frame update
    void Start()
    {
        //shielding = false;

        hpController = GetComponentInChildren <ShipHealth>();

        shieldDelayTimer = setShieldDelay;
    }
예제 #6
0
    private void Start()
    {
        h = GetComponent <ShipHealth>();

        damagePerSecond = h.MaxHealth / (timeLimit * 60);

        sunLight = Globals.GameVars.skybox_sun;
    }
예제 #7
0
 void Start()
 {
     if (player == null)
     {
         player = GameObject.Find("Player");
     }
     playerHealth = player.GetComponent <ShipHealth>();
 }
예제 #8
0
 void Start()
 {
     player      = GameObject.Find("Player");
     rigid       = this.GetComponent <Rigidbody>();
     shipHealth  = FindObjectOfType <ShipHealth>();
     audioSource = GetComponent <AudioSource>();
     audioSource.PlayOneShot(flightNoise, flightVolume);
     thisCollider = gameObject.GetComponent <CapsuleCollider>();
 }
예제 #9
0
        public void ShipTakeDamage(int damage, int expected)
        {
            // Use the Assert class to test conditions
            ShipHealth ship = new ShipHealth(10);

            ship.TakeDamage(damage);

            Assert.That(ship.GetHealth(), Is.EqualTo(expected));
        }
예제 #10
0
 private void Update()
 {
     if (m_target != null)
     {
         if (m_target.m_isDead || !m_target.gameObject.activeInHierarchy)
         {
             m_target = null;
         }
     }
 }
예제 #11
0
    private void Start()
    {
        planet = FindObjectOfType <ShipHealth>();

        if (planet != null)
        {
            planet.gameOver += Explode;
        }

        shipMat.DOColor(shipBaseColor, "_EmissionColor", 0);
    }
예제 #12
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
예제 #13
0
 // Use this for initialization
 void Start()
 {
     player                       = GameObject.Find("Player");
     shipHealth                   = FindObjectOfType <ShipHealth>();
     firePoint                    = GameObject.CreatePrimitive(PrimitiveType.Sphere);
     myCollider                   = firePoint.GetComponent <SphereCollider>();
     myCollider.isTrigger         = true;
     myMesh                       = firePoint.GetComponent <MeshRenderer>();
     myMesh.enabled               = false;
     firePoint.transform.position = player.transform.position;
 }
예제 #14
0
    protected new void Start()
    {
        base.Start();
        shipHealth = GetComponent <ShipHealth>();
        shipHealth.ReduceDamage = TakeDamage;

        if (CompareTag("Player"))
        {
            shieldBar = Array.Find(FindObjectsOfType <HealthBar>(), element => "Shield".Equals(element.barName));
        }
    }
예제 #15
0
 void Awake()
 {
     if (shipHealth == null)
     {
         shipHealth = this;
         DontDestroyOnLoad(GameObject.FindGameObjectWithTag("Player"));
     }
     else if (shipHealth != this)
     {
         Destroy(gameObject);
     }
 }
예제 #16
0
 // SphereCast to checks every Object within it
 void Explode()
 {
     Collider[] colliders = Physics.OverlapSphere(transform.position, m_explosionRadius);
     for (int i = 0; i < colliders.Length; i++)
     {
         ShipHealth targetInRange = colliders[i].GetComponent <ShipHealth>();
         if (targetInRange != null)
         {
             targetInRange.TakeDamage(m_damage);
         }
     }
 }
예제 #17
0
    void Hit(RaycastHit hit)
    {
        if (hit.transform.tag == "Ship" || hit.transform.tag == "Player")
        {
            ShipHealth sh = hit.transform.gameObject.GetComponent <ShipHealth>();
            sh.Hit(damage);
        }

        Instantiate(hitParticleSystem, hit.point, Quaternion.LookRotation(hit.normal));

        Destroy(gameObject);
    }
예제 #18
0
    private void OnTriggerEnter(Collider other)
    {
        // Collect all the colliders in a sphere from the shell's current position to a radius of the explosion radius.
        Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_ShipMask);

        // Go through all the colliders...
        for (int i = 0; i < colliders.Length; i++)
        {
            // ... and find their rigidbody.
            Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody> ();

            // If they don't have a rigidbody, go on to the next collider.
            if (!targetRigidbody)
            {
                continue;
            }

            // Add an explosion force.
            targetRigidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius);

            // Find the ShipHealth script associated with the rigidbody.
            ShipHealth targetHealth = targetRigidbody.GetComponent <ShipHealth> ();

            // If there is no ShipHealth script attached to the gameobject, go on to the next collider.
            if (!targetHealth)
            {
                continue;
            }

            // Calculate the amount of damage the target should take based on it's distance from the shell.
            float damage = CalculateDamage(targetRigidbody.position);

            // Deal this damage to the Ship.
            targetHealth.TakeDamage(damage);
        }

        // Unparent the particles from the shell.
        m_ExplosionParticles.transform.parent = null;

        // Play the particle system.
        m_ExplosionParticles.Play();

        // Play the explosion sound effect.
        m_ExplosionAudio.Play();

        // Once the particles have finished, destroy the gameobject they are on.
        Destroy(m_ExplosionParticles.gameObject, m_ExplosionParticles.main.duration);
        // Destroy (Instantiate(m_ExplosionParticles), m_ExplosionParticles.main.duration);

        // Destroy the shell.
        Destroy(gameObject);
    }
예제 #19
0
        public static ShipController GetShip(Game gameView, ShipModel shipModel)
        {
            IView         shipView         = gameView.CreateView(shipModel.Name);
            IShipMove     shipMove         = new ShipMove(shipView.Rigidbody2D, shipModel.MoveForce);
            IShipRotate   shipRotate       = new ShipRotate(shipView.Rigidbody2D, shipModel.Torque);
            IShipHealth   shipHealth       = new ShipHealth(shipModel.MaxHealth);
            IShipCollided shipCollided     = new ShipCollided(shipView, shipHealth);
            IShipFire     shipFire         = new ShipFire();
            FireLock      fireLock         = new FireLock();
            IShipFire     shipLockableFire = new ShipLockableFire(shipFire, fireLock);

            return(new ShipController(shipModel, shipView, shipMove, shipRotate, shipCollided, shipHealth, shipLockableFire, fireLock));
        }
예제 #20
0
        void AssignLastEnemyComponents()
        {
            lastEnemy = GameObject.Find(Names.Enemy);

            if (lastEnemy == null)
            {
                Debug.LogError("GameObject with Tag LastEnemy not found in LevelManager.cs!");
                return;
            }

            lastEnemyShip = lastEnemy.GetComponentInChildren <ShipHealth>();
            lastEnemyFire = lastEnemy.GetComponent <BaseFire>();
        }
예제 #21
0
    void Start()
    {
        player     = GameObject.Find("Player");
        shipHealth = FindObjectOfType <ShipHealth>();
        //rigid = this.GetComponent<Rigidbody>();

        //creating an invisible 'end point' where the player was last standing
        laserEnd              = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        endCollider           = laserEnd.GetComponent <SphereCollider>();
        endCollider.isTrigger = true;
        endMesh                     = laserEnd.GetComponent <MeshRenderer>();
        endMesh.enabled             = false;
        laserEnd.transform.position = player.transform.position;
    }
예제 #22
0
        void AssignPlayerComponents()
        {
            GameObject player = GameObject.Find(Names.Player);

            if (player == null)
            {
                Debug.LogError("GameObject with Tag Player not found in LevelManager.cs!");
                return;
            }

            playerShip     = player.GetComponentInChildren <ShipHealth>();
            playerMovement = player.GetComponent <IPlayerMovement>();
            playerFire     = player.GetComponent <PlayerFire>();
        }
예제 #23
0
    private void Start()
    {
        cm = CheckpointManager.instance;
        sc = StatCounter.instance;
        rb = GetComponent <Rigidbody2D>();
        rb.centerOfMass = Vector2.zero;
        fuel            = GetComponent <ShipFuel>();
        health          = GetComponent <ShipHealth>();

        goText.enabled = false;
        paused         = false;
        pausedText.gameObject.SetActive(paused);

        StartCoroutine(ShowText());
    }
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.ToString().Contains("PlayerShip"))
     {
         ShipHealth targetHealth = other.GetComponent <ShipHealth>();
         if (!targetHealth.GetShield())
         {
             targetHealth.takeDamage(damage);
             laserAudio.Play();
         }
         gameObject.transform.position = new Vector2(15, 20);
         Destroy(gameObject, 0.2f);
     }
     else if (other.ToString().Contains("ShieldLaser"))
     {
         Destroy(gameObject, 0.0f);
     }
 }
예제 #25
0
    void OnCollisionEnter(Collision collision)
    {
        // Find ShipHealth component in the object's highest parent
        Transform obj = collision.gameObject.transform;

        while (obj.parent != null)
        {
            obj = obj.parent;
        }
        ShipHealth health = obj.GetComponent <ShipHealth>();

        if (health?.gameObject == IgnoreCollisions)
        {
            return;
        }

        if (health != null)
        {
            health.Health--;
            Destroy(this.gameObject);

            ContactPoint contact      = collision.contacts[0];
            Vector3      vfxDirection = contact.normal;
            vfxDirection.y = Util.Cap(vfxDirection.y, 0.2f);
            vfxDirection.Normalize();

            GameObject vfx = Instantiate(CollisionVFXPrefab, contact.point, Quaternion.identity);
            vfx.transform.rotation = Quaternion.LookRotation(vfxDirection, Vector3.up);

            ParticleSystem particles        = vfx.GetComponentInChildren <ParticleSystem>();
            var            particleLifetime = particles.main.startLifetime;
            float          vfxTime          = particles.main.duration + particleLifetime.constant;
            Destroy(vfx, vfxTime);

            var velocityModule = particles.velocityOverLifetime;
            velocityModule.x = health.Velocity.x * 10;
            velocityModule.y = health.Velocity.y * 10;
            velocityModule.z = health.Velocity.z * 10;
        }
    }
예제 #26
0
    // Start is called before the first frame update
    void Start()
    {
        currentState = GameState.Setup;

        breakTimer = 0;

        levelPrompt     = GameObject.Find("Level Prompt");
        levelPromptText = levelPrompt.GetComponent <Text>();
        levelPrompt.SetActive(false);

        damageUpPrompt = GameObject.Find("Damage Up Prompt");
        damageUpPrompt.SetActive(false);

        tripleShotPrompt = GameObject.Find("Triple Shot Prompt");
        tripleShotPrompt.SetActive(false);

        scoreUpPrompt = GameObject.Find("Score Up Prompt");
        scoreUpPrompt.SetActive(false);

        healthUpPrompt = GameObject.Find("Health Up Prompt");
        healthUpPrompt.SetActive(false);

        coroutineStarted = false;

        scoreMultiplier = 1;

        scoreMultiplierText.text = scoreMultiplier.ToString() + "x";

        baseMultiplier = 1;

        playerHp = GameObject.Find("Ship").GetComponentInChildren <ShipHealth>();

        dropped        = false;
        bossDropSystem = GetComponent <BossDropSystem>();

        transitionController = Camera.main.GetComponent <TransitionController>();

        blockerSpawnerScripts = blockerSpawners.GetComponentsInChildren <MultiSpawner>();
    }
예제 #27
0
    void OnTriggerEnter(Collider other)
    {
        // Ignore if other is sibling
        if (other.tag == tag)
        {
            return;
        }

        // Enemy bullet
        if (other.tag.Contains(Tags.Bullet) && !other.tag.Contains(tag))
        {
            TakeDamage();
            other.transform.parent.gameObject.SetActive(false);
        }

        // Physical collision with ship
        ShipHealth otherHealth = other.transform.parent.GetComponentInChildren <ShipHealth>();

        if (otherHealth != null)
        {
            otherHealth.TakeDamage();
        }
    }
    private void Start()
    {
        h = GetComponent <ShipHealth>();

        damagePerSecond = h.MaxHealth / (timeLimit * 60);
    }
예제 #29
0
 // Use this for initialization
 public MeterMessager(Power power, ShipHealth shipHealth, EnemyManager enemyManager)
 {
     m_Power        = power;
     m_ShipHealth   = shipHealth;
     m_EnemyManager = enemyManager;
 }
예제 #30
0
 private void OnTriggerEnter(Collider other)
 {
     m_target = other.GetComponent <ShipHealth>();
 }