Beispiel #1
0
    void Awake()
    {
        var player = GameObject.FindWithTag("Player");

        playerMoveCon   = player.GetComponent <PlayerMovement>();
        playerAttackCon = player.GetComponent <PlayerAttackController>();
    }
    // Use this for initialization
    void Start()
    {
        hp    = 3;
        lives = 3;
        alive = true;
        isHit = false;

        sp       = GetComponent <SpriteRenderer>();
        animator = GetComponent <Animator>();

        mainCam = GameObject.Find("Main Camera");

        attackController = GetComponent <PlayerAttackController>();

        isFacingRight   = true;
        spriteCanChange = true;
        respawnPosition = transform.position;

        rb = GetComponent <Rigidbody2D>();

        invulnerable = false;

        pinwheeling = false;
        invisTimer  = 0;

        isGrounded = true;
    }
Beispiel #3
0
 void Start()
 {
     theHourglass      = GameObject.FindGameObjectWithTag("OfficialHourGlass");
     hourglassControls = theHourglass.GetComponent <TheHourglass>();
     perfectWindow     = false;
     buttonMash        = 0;
     spellName         = "";
     showHelpText      = true;
     hitSounds         = GetComponents <AudioSource>();
     swing1            = hitSounds[0];
     swing2            = hitSounds[1];
     swing3            = hitSounds[2];
     cam = GameObject.FindGameObjectWithTag("MainCamera");
     listenForComboInput = false;
     discreteInputWindow = false;    //Used to prevent multiple presses within a short timeframe
     pauseHourglass      = true;
     anim              = this.gameObject.GetComponent <Animator>();
     attackController  = this.gameObject.GetComponent <PlayerAttackController>();
     step1Damage       = 1;
     step1Damage       = 2;
     step1Damage       = 3;
     spellDamageToDeal = 3;
     castFirstFail     = true; //if first button missed, need a way to not auto cast lvl1 spell
     rangedAbilityFlag = false;
 }
    void Awake()
    {
        // Set up references.
        anim            = GetComponent <Animator>();
        playerRigidbody = GetComponent <Rigidbody>();
        capsuleCollider = GetComponent <CapsuleCollider>();

        attackCon = GetComponent <PlayerAttackController>();
    }
    void Start()
    {
        _cameraController   = GetComponentInChildren <PlayerCameraController>();
        _movementController = GetComponent <PlayerMovementController>();
        _jumpController     = GetComponent <PlayerJumpController>();
        _attackController   = GetComponent <PlayerAttackController>();

        Cursor.visible = false;
    }
Beispiel #6
0
    void Start()
    {
        HealthBar = GameObject.Find("HealthBar_Enemy").GetComponent <Slider>();
        player    = GameObject.FindWithTag("Player");
        playerAttackController = player.GetComponent <PlayerAttackController>();
        HealthBar_Enemy_Back   = GameObject.Find("HealthBar_Enemy_Back").GetComponent <Image>();
        HealthBar_Enemy_Fill   = GameObject.Find("HealthBar_Enemy_Fill").GetComponent <Image>();

        HideEnemyHub();
    }
Beispiel #7
0
        /// <summary>
        /// Aumenta e persiste o highscore do jogador
        /// </summary>
        public void giveScore()
        {
            GameObject player = PlayerData.spaceship;

            if (player != null)
            {
                PlayerAttackController playerController = player.GetComponent <PlayerAttackController>();
                if (player != null)
                {
                    playerController.score.Value += scoreReward;
                }
            }
        }
    private void CreateAttack()
    {
        PlayerStatsController  targetStatsController = target.gameObject.GetComponent <PlayerStatsController>();
        PlayerAttackController targetAttackHandler   = target.gameObject.GetComponent <PlayerAttackController>();

        if (targetStatsController == null || targetAttackHandler == null)
        {
            return;
        }

        Attack attack = arrowShootingDefinition.EnemyCreateAttack(shooterStatsController, targetStatsController, arrowShootingDefinition.hitBackForce);

        targetAttackHandler.OnAttacked(this.gameObject, attack);
    }
Beispiel #9
0
    private void CheckRespawn()
    {
        if (Time.time >= respawnTimeStart + RespawnTime && respawn)
        {
            isPlayerDead = false;

            float respawnHealth = soulFragmentsCollected / 4;


            HeartsHealthVisual.instance.SetHealthBar(respawnHealth);
            playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController_Hero>();
            attackController = GameObject.FindGameObjectWithTag("PlayerSpriteObject").GetComponent <PlayerAttackController>();
            attackController.SetupHealth(soulFragmentsCollected);
        }
    }
Beispiel #10
0
    public override void TriggerAttack()
    {
        base.TriggerAttack();

        Collider2D[] hittedEnemies = Physics2D.OverlapCircleAll(enemyController.meleeAttackPosition.position, meleeAttack.radiusRange, enemyData.whatIsPlayer);
        foreach (Collider2D enemy in hittedEnemies)
        {
            Attack attack = meleeAttack.EnemyCreateAttack(enemyController.statsController, enemy.gameObject.GetComponent <PlayerStatsController>(), meleeAttack.hitBackForce);
            PlayerAttackController playerAttackController = enemy.gameObject.GetComponent <PlayerAttackController>();
            if (playerAttackController != null)
            {
                playerAttackController.OnAttacked(enemyController.gameObject, attack);
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        hp    = 3;
        lives = 3;

        sp       = GetComponent <SpriteRenderer>();
        animator = GetComponent <Animator>();

        mainCam = GameObject.Find("Main Camera");

        attackController = GetComponent <PlayerAttackController>();

        isFacingRight   = true;
        spriteCanChange = true;
    }
Beispiel #12
0
    // Use this for initialization
    void Start()
    {
        theHourglass            = GameObject.FindGameObjectWithTag("OfficialHourGlass");
        hourglassControls       = theHourglass.GetComponent <TheHourglass>();
        comboController         = this.gameObject.GetComponent <ComboController>();
        comboController.enabled = false;
        Invoke("initializeController", 1f); //allows player time to teleport to start

        cam = GameObject.FindGameObjectWithTag("MainCamera");
        attackController = this.gameObject.GetComponent <PlayerAttackController>();
        //UI 3 buttons, 4th button is switch panel
        abilitiesUI    = new GameObject[3];
        abilitiesUI[0] = abil1UI;
        abilitiesUI[1] = abil2UI;
        abilitiesUI[2] = abil3UI;
        exploreMode    = false;
    }
Beispiel #13
0
    // Use this for initialization
    void Start()
    {
        hp    = 3;
        lives = 3;
        alive = true;

        mainCam = GameObject.Find("Main Camera");

        attackController = GetComponent <PlayerAttackController>();

        isFacingRight   = true;
        spriteCanChange = true;

        tilemapCollider = GameObject.Find("Tilemap").GetComponent <Collider2D>();

        grounded  = true;
        isJumping = false;
    }
Beispiel #14
0
    public void TakeDamage(int amount, PlayerAttackController playerAttackController)
    {
        if (playerAttackControllers.Any(x => x == playerAttackController))
        {
            return;
        }
        else
        {
            playerAttackControllers.Add(playerAttackController);
        }
        //Debug.Log("TakeDamage" + amount);
        // If the enemy is dead...
        if (isDead)
        {
            // ... no need to take damage so exit the function.
            return;
        }

        // Play the hurt sound effect.
        //enemyAudio.Play();

        // Reduce the current health by the amount of damage sustained.
        currentHealth -= amount;

        healthBar.fillAmount = currentHealth / startingHealth;

        // Set the position of the particle system to where the hit was sustained.
        //hitParticles.transform.position = hitPoint;

        // And play the particles.
        //hitParticles.Play();

        // If the current health is less than or equal to zero...
        if (currentHealth <= 0)
        {
            // ... the enemy is dead.
            Death();
        }
    }
Beispiel #15
0
 // Update is called once per frame
 void Update()
 {
     if (healthController.IsAlive)
     {
         playerController.MoveCharacter(body, speed);
         if (Time.timeScale != 0)
         {
             playerController.MouseRotation(transform);
         }
         if (Input.GetButtonDown("Fire1"))
         {
             PlayerAttackController attackController = new PlayerAttackController();
             attackController.Attack(new StandartPlayerAttack(gameObject));
         }
     }
     else
     {
         body.rotation = 0;
         body.velocity = Vector2.zero;
         Destroy(gameObject);
         SceneManager.LoadScene("GameOverScene");
     }
 }
#pragma warning disable 0414

    void Awake()
    {
        if (!PhotonNetwork.connected)
        {
            Destroy(this);
        }

        if (!this.isMine)
        {
            if (HeatTarget.gameObject.activeSelf == false)
            {
                HeatTarget.gameObject.SetActive(true);
            }
        }

        m_PositionControl = new PhotonTransformViewPositionControl(m_PositionModel);
        m_RotationControl = new PhotonTransformViewRotationControl(m_RotationModel);
        m_ScaleControl    = new PhotonTransformViewScaleControl(m_ScaleModel);
        Controller        = this.GetComponent <bl_PlayerMovement>();
        weaponController  = this.GetComponent <PlayerWeaponController>();
        weaponChange      = this.GetComponent <PlayerWeaponChange>();
        attackController  = this.GetComponent <PlayerAttackController>();
    }
 private void Start()
 {
     pac = GetComponent <PlayerAttackController>();
     pcc = GetComponent <PlayerCameraController>();
     pmc = GetComponent <PlayerMovementController>();
 }
Beispiel #18
0
    IEnumerator StartLevel()
    {
        yield return(new WaitForSeconds(1f));

        //restartButton.SetActive(false);


        mainCamera = Camera.main;

        currentLevel = SceneManager.GetActiveScene().buildIndex;


        if (SceneManager.GetActiveScene().name != "Level_Soul")
        {
            LevelEndImage = GameObject.Find("SceneTransition");
            LevelEndImage.SetActive(true);

            GameSettings.GetSettings();

            if (SceneManager.GetActiveScene().name == "Tutorial")
            {
                maxHealth           = GameSettings.playerMaxHealth;
                currentPlayerHealth = maxHealth;
                NumberOfJumps       = 1;
            }
            else
            {
                RespawnPoint          = GameObject.FindGameObjectWithTag("RespawnPoint").transform;
                RespawnPoint.position = PlayerStats.currentRespawnPoint;
                if (RespawnPoint.position == Vector3.zero)
                {
                    RespawnPoint.position = GameObject.Find("PlayerFirstSpawnPoint").transform.position;
                }

                Instantiate(playerPrefab, RespawnPoint.position, Quaternion.identity);

                NumberOfJumps = 2;
                if (SceneManager.GetActiveScene().name != "EndScene")
                {
                    currentPlayerHealth = PlayerStats.playerHealth;
                    maxHealth           = PlayerStats.playerMaxHealth;
                    diamondsCollected   = PlayerStats.playerDiamondsCollected;
                    enemiesKilled       = PlayerStats.enemiesKilled;
                    diamondCount        = GameObject.Find("DiamondCount").GetComponent <TMP_Text>();
                    diamondCount.text   = diamondsCollected.ToString();
                }
            }

            cameraController = mainCamera.GetComponentInParent <CameraController_Hero>();
            playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController_Hero>();
            attackController = GameObject.FindGameObjectWithTag("PlayerSpriteObject").GetComponent <PlayerAttackController>();

            if (SceneManager.GetActiveScene().name != "Tutorial" && SceneManager.GetActiveScene().name != "EndScene")
            {
                GetPlayerStats();
            }


            playerController.SetupPlayer();
            attackController.SetupPlayer();
            cameraController.SetupCamera();

            if (SceneManager.GetActiveScene().name != "EndScene")
            {
                HeartsHealthVisual.instance.SetHealthBar(maxHealth / 4);
                HeartsHealthVisual.healthSystem.Damage((int)(maxHealth - currentPlayerHealth));
                attackController.SetupHealth(currentPlayerHealth);

                enemySpawner = GameObject.FindGameObjectWithTag("EnemySpawner").GetComponent <EnemySpawner>();

                enemySpawner.enemiesCloned   = GameSettings.enemies;
                enemySpawner.usedSpawnPoints = GameSettings.usedPoints;

                enemySpawner.SetupEnemies();
            }
            if (GameObject.FindGameObjectWithTag("ExitDoor") != null)
            {
                exitDoor = GameObject.FindGameObjectWithTag("ExitDoor").GetComponent <DoorOpen>();
            }

            if (SceneManager.GetActiveScene().name != "Tutorial")
            {
                enableDash();
                enableDoubleJump();
                enableJump();
                enemiesInLevel = GameSettings.EnemyCount;
            }
            else if (SceneManager.GetActiveScene().name == "Tutorial")
            {
                enemiesInLevel     = 1;
                skipTutorialButton = GameObject.Find("SkipTut").GetComponent <Button>();
                skipTutorialButton.interactable = true;
            }

            isLevelActive = true;
        }
    }
 // Use this for initialization
 void Start()
 {
     attackCtrlr = GetComponent <PlayerAttackController>();
     Invoke("setAttackControls", 1f);
 }
 void InitializeWeapon()
 {
     attackController    = gameObject.GetComponent <PlayerAttackController>();
     weaponBoxCollider2D = gameObject.GetComponent <BoxCollider2D>();
     renderObject        = gameObject.GetComponent <SpriteRenderer>();
 }