void Awake()
 {
     myRigidbody                  = GetComponent <Rigidbody2D>();
     animatorController           = GetComponent <Animator>();
     lifeController               = GetComponent <LifeController>();
     currentMana                  = maxMana;
     canAttack                    = true;
     lifeController.OnTakeDamage += OnTakeDamageListener;
 }
    // Use this for initialization
    void Awake()
    {
        lc = GetComponentInParent<LifeController> ();
        slider = GetComponent<Slider> ();

        slider.maxValue = lc.lives;
        slider.value = lc.lives;
        slider.minValue = 0;
    }
 // Start is called before the first frame update
 void Start()
 {
     ballRb            = GetComponent <Rigidbody2D>();
     lifeCounterObject = GameObject.FindGameObjectWithTag("LifeCounter");
     if (lifeCounterObject != null)
     {
         lifeScript = lifeCounterObject.GetComponent <LifeController>();
     }
 }
Beispiel #4
0
    // Use this for initialization
    void Awake()
    {
        lc     = GetComponentInParent <LifeController> ();
        slider = GetComponent <Slider> ();

        slider.maxValue = lc.lives;
        slider.value    = lc.lives;
        slider.minValue = 0;
    }
Beispiel #5
0
 public void RestartLevel()
 {
     dialogueController = GameObject.FindGameObjectWithTag("Controllers").GetComponent <DCLevel>();
     if (!dialogueController.Displaying())
     {
         lifeController = GameObject.FindGameObjectWithTag("Controllers").GetComponent <LifeController>();
         HideMenu();
         lifeController.RestartLevel();
     }
 }
 protected virtual void Start()
 {
     dead                 = false;
     lifeController       = GetComponent <LifeController>();
     characterOrientation = Vector2.down;
     movementDirection    = Vector2.down;
     rbody                = GetComponent <Rigidbody2D> ();
     anim                 = GetComponent <Animator> ();
     rbody.velocity       = Vector3.zero;
 }
 void Start()
 {
     lifeController = GetComponent <LifeController>();
     lifeController.OnChangeCurrentLife.AddListener(OnCurrentLifeListener);
     UpdateLifeBar();
     if (lifeController.GetCurrentLifePercentage() == 0)
     {
         lifeBar.fillAmount = lifeController.GetMaxLife();
     }
 }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        LifeController life = collision.GetComponent <LifeController>(); //Si el item tiene un life controller.... (ya la matrix de fisica va decidir si detecta la collision)

        if (life != null)                                                //si no tiene un life controller el item con el que collisiono, va a ser null.
        {
            life.TakeDamage(damage);
            Destroy(gameObject);
        }
    }
Beispiel #9
0
 public void KeepOnlyOneInstance()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
 }
Beispiel #10
0
 private void Start()
 {
     anim = GetComponent<Animator>();
     lifeController = new LifeController(maxLife);
     lifeController.OnGetDamage += OnGetDamageHandler;
     lifeController.OnGetHeal += OnGetHealHandler;
     lifeController.OnDead += OnDeadHandler;
     sprRend = GetComponent<SpriteRenderer>();
     playerShootingController = GetComponent<PlayerShootingController>();
     Gamemanager.instance.UI.UpdateHealth(lifeController.CurrentLife);
 }
Beispiel #11
0
 private void OnCollisionEnter2D(Collision2D other)
 {
     Instantiate(destroyEffect, transform.position, Quaternion.identity);
     Destroy(gameObject);
     if (other.gameObject.tag == "Player")
     {
         LifeController lives = other.gameObject.GetComponent <LifeController>();
         lives.lives--;
         FMODUnity.RuntimeManager.PlayOneShot("Event:/SFX/Hit");
     }
 }
Beispiel #12
0
    void OnCollisionEnter(Collision collision)
    {
        for (int i = 0; i < collisionDetect_IgnoreLayers.Length; i++)
        {
            string layerName = collisionDetect_IgnoreLayers[i];

            int layer = LayerMask.NameToLayer(layerName);

            if (collision.transform.gameObject.layer == layer)
            {
                return;
            }
        }

        for (int i = 0; i < collisionDetect_IgnoreTags.Length; i++)
        {
            string tagName = collisionDetect_IgnoreTags[i];

            if (collision.transform.gameObject.CompareTag(tagName))
            {
                return;
            }
        }


        ContactPoint contectPoint = collision.contacts[0];

        for (int i = 0; i < hitExplosionDataArray.Length; i++)
        {
            int detectLayer = hitExplosionDataArray[i].effectItem.gameObject.layer;

            if (collision.transform.root.gameObject.layer == detectLayer)
            {
                m_MissileExplosionPoolDictionary[detectLayer].SpawnGameObjectPoolItem(contectPoint.point + contectPoint.normal * 0.05f, Quaternion.LookRotation(contectPoint.normal));

                break;
            }
        }

        GameObject hitRootGameObject = collision.transform.root.gameObject;

        LifeController lifeController = hitRootGameObject.GetComponent <LifeController>();

        if (lifeController != null)
        {
            lifeController.TakeDamage(damageTargetValue);
        }

        m_TrailHandler.Detach();

        m_TrailHandler = null;

        Recycle();
    }
    // Use this for initialization
    void Start()
    {
        lifeController       = GameObject.Find("LifeController");
        life                 = lifeController.GetComponent <LifeController>();
        life.initialPosition = transform.position;
        life.currentPosition = transform.position;
        fadeLevel            = GameObject.Find("FadeLevel");
        levelScript          = fadeLevel.GetComponent <LevelChanger>();

        Cursor.visible = false;
    }
 // Use this for initialization
 void Start()
 {
     if (!Instance)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
     Init();
 }
Beispiel #15
0
    // Use this for initialization
    void Start()
    {
        alive     = Instantiate(enemy, alivePos.position, alivePos.rotation);
        dead      = Instantiate(enemy, deadPos.position, deadPos.rotation);
        aliveBody = Instantiate(aliveBodyObject, alivePos.position, alivePos.rotation);
        deadBody  = Instantiate(deadBodyObject, deadPos.position, deadPos.rotation);
        aliveLC   = alive.GetComponent <LifeController>();
        deadLC    = dead.GetComponent <LifeController>();

        aliveLC.SetDC(this);
        deadLC.SetDC(this);
    }
Beispiel #16
0
 public void GoToStart()
 {
     GameCicle.Pause = false;
     CreateBlocks(LevelConfiguration);
     ScoreController.GoToStart();
     LifeController.GoToStart();
     Player.GoToStart();
     Player.ResetWidth();
     _currentPlayerPosition = LevelConfiguration.PlayerStartPosition.x;
     BallController.GoToStart(Vector2.one * BallEnergy);
     RemainingTime = TimeSpan.FromSeconds(LevelConfiguration.StartTime);
     BonusManager.Release();
 }
Beispiel #17
0
 public void selectCell(LifeController lc)
 {
     selected = lc;
     if (lc != null)
     {
         nCamera.enabled = true;
     }
     else
     {
         nCamera.enabled = false;
         setDescriptiveText("Nothing Selected.");
     }
 }
 private void Awake()
 {
     achievementCount  = 0;
     isCharacterCreate = false;
     createCount       = 0;
     isGameSet         = false;
     lifeController    = GetComponent <LifeController>();
     createTime        = Constant.GameMain.NextDelayTime;
     gameObject.GetComponent <ObjectActiveController>().OnGaugeActive();
     sceneChangeCount = 0;
     isSuccess        = false;
     isFailure        = false;
 }
Beispiel #19
0
    private IEnumerator PerformAttack(LifeController target)
    {
        if (AttackSound)
        {
            AudioSource.PlayClipAtPoint(AttackSound, Camera.main.transform.position, 0.4f);
        }

        IsAttacking = true;
        target.ReceiveDamage();
        yield return(new WaitForSeconds(AttackDuration));

        IsAttacking = false;
    }
Beispiel #20
0
 void Start()
 {
     colorController = gameObject.GetComponent <ColorController>();
     if (colorController.GetColor() == 1)
     {
         this.GetComponent <SpriteRenderer>().color = new Color(0.5f, 0.5f, 1f, 1f);
     }
     else
     {
         this.GetComponent <SpriteRenderer>().color = new Color(1f, 0.4f, 0.4f, 1f);
     }
     lifeController = gameObject.GetComponent <LifeController>();
 }
Beispiel #21
0
 private void Start()
 {
     LifeController              = new LifeController(maxLife);
     anim                        = GetComponent <Animator>();
     AIController                = GetComponent <AIController>();
     LifeController.OnGetDamage += OnGetDamageHandler;
     LifeController.OnDead      += OnDeadHandler;
     checkNearPlayer.enabled     = true;
     audioSrc                    = GetComponent <AudioSource>();
     rb         = GetComponent <Rigidbody2D>();
     sprRend    = GetComponent <SpriteRenderer>();
     timerToDie = dieSound.length;
     NewTimerToGrunt();
 }
Beispiel #22
0
    // Use this for initialization
    private void Start()
    {
        rigidbody = GetComponent <Rigidbody>();

        if (rigidbody != null)
        {
            rigidbody.AddForce(Vector3.down * 5F, ForceMode.Impulse);
        }

        paddle = GameObject.Find("Paddle").GetComponent <Transform>();
        vida   = GetComponent <LifeController>();
        Reiniciar();
        latPos = transform.position;
    }
Beispiel #23
0
    private void PhysicsLineDetect()
    {
        RaycastHit hitInfo;

        Vector3 currentDetectPoint = detectPoint.position;


#if UNITY_EDITOR
        // helper to visualise the ground check ray in the scene view
        Debug.DrawLine(m_LastDetectPointPos, currentDetectPoint, Color.red);
#endif

        if (Physics.Linecast(m_LastDetectPointPos, currentDetectPoint, out hitInfo) == true)
        {
            for (int i = 0; i < collisionDetect_IgnoreLayers.Length; i++)
            {
                string layerName = collisionDetect_IgnoreLayers[i];

                int layer = LayerMask.NameToLayer(layerName);

                if (hitInfo.transform.gameObject.layer == layer)
                {
                    return;
                }
            }

            for (int i = 0; i < collisionDetect_IgnoreTags.Length; i++)
            {
                string tagName = collisionDetect_IgnoreTags[i];

                if (hitInfo.transform.gameObject.CompareTag(tagName))
                {
                    return;
                }
            }

            m_LaserImpactPool.SpawnGameObjectPoolItem(hitInfo.point, Quaternion.LookRotation(hitInfo.normal));

            GameObject hitRootGameObject = hitInfo.transform.root.gameObject;

            LifeController lifeController = hitRootGameObject.GetComponent <LifeController>();

            if (lifeController != null)
            {
                lifeController.TakeDamage(damageTargetValue);
            }

            Recycle();
        }
    }
Beispiel #24
0
    // Use this for initialization
    void Start()
    {
        // text = GetComponent<Text>();
        //(replaced with slider)
        healthBar = GetComponent <Slider>();

        // Set Health to saved health value.
        playerHealth = PlayerPrefs.GetInt("CurrentPlayerHealth");

        // Get LevelManger
        timeController = FindObjectOfType <TimeController>();
        levelManager   = FindObjectOfType <LevelManager>();
        lifeController = FindObjectOfType <LifeController>();
        isAlive        = true;
    }
Beispiel #25
0
    void Start()
    {
        lifeController = player.GetComponent <LifeController>();
        lifeController.OnChangeCurrentLife.AddListener(OnCurrentLifeListener);
        lifeController.OnRespawnLife.AddListener(OnRespawnLifeListener);
        playerCurrentHearts = lifeController.GetMaxLife(); //Como es un solo nivel, siempre traemos el maximo de vida

        for (int i = 0; i < playerCurrentHearts; i++)      //Y con esto inicializamos la vida
        {
            GameObject newHeart = Instantiate(heart);
            newHeart.transform.parent = gameObject.transform;
            hearts.Add(newHeart);
            currentHearts++;
        }
    }
Beispiel #26
0
    private void Awake()
    {
        if (players.Count == 0)
        {
            var pps = GameObject.FindGameObjectsWithTag("Player");
            players.AddRange(pps);
        }

        //GameStatus.enemyAliveCount++;
        lifeController = new LifeController();
        //lifeController.OnDeadCallBack += GameManager.instance.EnemyDie;
        lifeController.OnDeadCallBack += Die;
        startRotation = transform.eulerAngles;
        weapon        = new EnemyWeapon(shootPoint, Constants.layerEnemy);
        StartCoroutine(RandomTarget());
    }
    void OnTriggerEnter(Collider col)
    {
        Multitag multiTagObject = col.gameObject.GetComponent <Multitag>();

        if (multiTagObject != null && !collisionObjects.Contains(col.gameObject))
        {
            collisionObjects.Add(col.gameObject);
            bool isTagCollieder = col.gameObject.GetComponent <Multitag>().containsTagInList(SwordSc.tagsTrigger);

            if (isTagCollieder && col.gameObject.GetComponentInChildren <LifeController>() != null)
            {
                LifeController targetLifeC = col.gameObject.GetComponentInChildren <LifeController>();
                targetLifeC.TakeDamage(SwordSc.attack);
            }
        }
    }
Beispiel #28
0
    // Update is called once per frame
    void Update()
    {
        if (!IsAttacking && lifeController.IsAlive)
        {
            Collider2D enemy = Physics2D.OverlapCircle(transform.position, AttackRange, TargetLayer);

            if (enemy)
            {
                LifeController lifeController = enemy.gameObject.GetComponent <LifeController>();
                if (lifeController && lifeController.IsAlive)
                {
                    StartCoroutine(PerformAttack(lifeController));
                }
            }
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        audioSource = gameObject.AddComponent <AudioSource>();

        anim  = GetComponent <Animator>();
        movef = false;
        scale = transform.localScale;

        sposition = transform.position;

        LifeUI    = GameObject.Find("UIManager");
        uimanager = LifeUI.GetComponent <LifeController>();

        evomode  = false;
        nextTime = Time.time;
    }
Beispiel #30
0
 void Start()
 {
     currentLevel = 0;
     finalLevel   = false;
     menu         = GameObject.FindGameObjectWithTag("Menu");
     clips        = anims[0].runtimeAnimatorController.animationClips;
     lifecontrol  = GetComponent <LifeController>();
     for (int j = 0; j < clips.Length; j++)
     {
         if (clips[j].name == "Level Disappear 01")
         {
             time = clips[j].length;
         }
     }
     MainMenu.GetComponent <Animator>().Play("Fade In");
     Camera.main.GetComponent <Animator>().Play("MusicFadeIn");
 }
Beispiel #31
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")   //Si el item que collisiona tiene un tag de player...
     {
         LifeController life = collision.GetComponent <LifeController>();
         if (canHeal && life.CanHeal())
         {
             canHeal        = false;          //Solo deberia curar una vez.
             sprite.enabled = false;          //Desactivame el animator y el sprite renderer. Además toca el sonido.
             healLight.SetActive(false);
             healSound.Play();
             life.TakeHeal(heal);                 //Cura al jugador, cambia la variable de destruiye y setear el timer.
             canDestroy = true;
             timer     += Time.time;
         }
     }
 }
 // Use this for initialization
 private void Awake()
 {
     life = GetComponent<LifeController>();
     audioSource = GetComponent<AudioSource>();
     anim = GetComponent<Animator>();
 }
 // Use this for initialization
 void Awake()
 {
     rb = GetComponent<Rigidbody2D>();
     lc = GetComponent<LifeController>();
     anim = GetComponent<Animator>();
 }
Beispiel #34
0
 void Awake()
 {
     _instance = this;
 }
Beispiel #35
0
 // Use this for initialization
 void Start()
 {
     anim = GetComponent<Animator>();
     rb = GetComponent<Rigidbody2D>();
     lifeC = GetComponent<LifeController>();
     audioSource = GetComponent<AudioSource>();
     maxSpeed = speed;
 }