Пример #1
0
    /// <summary>
    /// Unity Function. Collision checker if the breakable object was hit by the hammer.
    /// </summary>
    /// <param name="collision">Collision</param>
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (!isBroken)
        {
            if (collision.collider.gameObject.layer == LayerMask.NameToLayer("HammerBreaker"))                // Hammer
            {
                HammerObject hammer = collision.collider.gameObject.GetComponentInParent <HammerObject> ();
                if (hammer.IsAttacking())
                {
                    this.Break();
                }
            }
            else if (collision.collider.gameObject.GetComponent <NeedleController>() != null)             // Needle
            {
                Debug.Log("NEEDLE HAS HIT");
                NeedleThrowing   needleThrowing = collision.collider.gameObject.GetComponent <NeedleThrowing> ();
                NeedleController needle         = collision.collider.gameObject.GetComponent <NeedleController> ();
                needleThrowing.setPullTowards(false);
                needleThrowing.setHookPullTowards(false);
                needle.hasHit = true;
//				NeedleController needle = collision.collider.gameObject.GetComponent<NeedleController>();
//				Break ();
            }
        }
    }
Пример #2
0
 public void InitiateLCD(int yarnballDenominator, EnemyHealth enemyHealth, HammerObject hammer)
 {
     if (this.lcdInterfaceReference != null)
     {
         this.lcdInterfaceReference.InitiateLCD(yarnballDenominator, enemyHealth, hammer);
     }
 }
Пример #3
0
 public HammerObject GetHammerObject()
 {
     if (this.hammer == null)
     {
         this.hammer = GetPlayer().GetPlayerAttack().getHammerObject();
     }
     return(this.hammer);
 }
Пример #4
0
 private void Deactivate()
 {
     yarnballBlock.PurgeBlocks();
     enemyValueBlock.PurgeBlocks();
     enemyHealthReference = null;
     hammerReference      = null;
     for (int i = 0; i < this.transform.childCount; i++)
     {
         this.transform.GetChild(i).gameObject.SetActive(false);
     }
 }
Пример #5
0
    public void InitiateLCD(int yarnballDenom, EnemyHealth enemyHealth, HammerObject hammer)
    {
        GameController_v7.Instance.GetPauseController().Pause();
        Activate();
        this.enemyHealthReference = enemyHealth;
        //NOTE: commented out due to error after EnemyHealth was updated
//		this.lcdNumberLine.Segment (this.enemyHealthReference.GetDenominator ());
//		this.lcdNumberLine.TargetSetter (this.enemyHealthReference.GetTargetNumerator (), this.enemyHealthReference.GetDenominator());
//		this.lcdNumberLine.InitialPointerPointTo (this.enemyHealthReference.GetInitialPointerNumerator (), this.enemyHealthReference.GetDenominator());
//		this.hammerReference = hammer;
//		InitiateBlocks (yarnballDenom, enemyHealthReference.GetDenominator ());
    }
Пример #6
0
    private void PropelYarnball(Vector3 direction, HammerObject hammer)
    {
        Debug.Log("Entered Propel");
        YarnballProjectile yarnProjectile = Instantiate <YarnballProjectile> (yarnBallProjectile, this.transform.position, Quaternion.identity);

        yarnProjectile.SetTarget(direction);
        yarnProjectile.SetDenominator(this.denominator);
        yarnProjectile.SetSource(this);
        yarnProjectile.SetHammer(hammer);
        yarnProjectile.gameObject.SetActive(true);
        yarnProjectile.Propel();
        Debug.Log("Exited Propel");
    }
Пример #7
0
 /// <summary>
 /// Awakes this instance.
 /// </summary>
 void Awake()
 {
     tag    = "Player";
     hammer = Instantiate(hammerPrefab, transform.position, Quaternion.identity);
     hammer.transform.SetParent(this.gameObject.transform);
     hammerAttack = hammer.GetComponent <HammerObject> ();
     hammerAttack.SetEffectHammerCharge(this.effectHammerCharge);
     hammerAnimator              = hammerAttack.GetComponentInChildren <Animator> ();
     this.hammerChildCollider    = hammerAttack.getHammerChildCollider();
     hammerChildCollider.enabled = false;
     GameController_v7.Instance.GetPauseController().onPauseGame    += this.DisableAttackOnPause;
     GameController_v7.Instance.GetPauseController().onContinueGame += this.EnableAttackOnContinue;
 }
Пример #8
0
    private IEnumerator ChoosingYarnballDirection(HammerObject hammer)
    {
        Vector3 mouseDirection;

        isStruck              = true;
        this.hammerMidSmash   = true;
        this.YuniIsPropelling = true;
        int cnt = 0;

//		while(this.hammerMidSmash) {
//		yield return new WaitForSeconds (0.5f);
//			yield return null;
//		}
        Debug.Log("Exited Yield");


        EventBroadcaster.Instance.PostEvent(EventNames.ON_LCD_PAUSE);
        GameController_v7.Instance.GetPauseController().Pause();
//		pauseController.PauseGame ();
        while (isStruck)
        {
            hammer.IsAttacking(true);
            yield return(null);

            //will have to add checker for android or windows // TODO Mobile compatibility
            if (Input.GetButtonDown("Fire1"))
            {
                mouseDirection = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                EventBroadcaster.Instance.PostEvent(EventNames.ON_LCD_UNPAUSE);


                if (pedestal != null)
                {
                    pedestal.DisableEffects();
                }
                GameController_v7.Instance.GetPauseController().Continue();
//				pauseController.ContinueGame ();
//				while(this.YuniIsPropelling) {
//					Debug.Log ("Yuni is propelling");
//					yield return null;
//				}


                PropelYarnball(mouseDirection, hammer);
                isStruck = false;
                hammer.IsAttacking(false);
            }
        }
        StartCoroutine(Cooldown());
        Debug.Log("Exited Choosing Yarnball");
    }
Пример #9
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (!this.isCharged)
        {
            if (other.CompareTag("Hammer Child"))
            {
                Debug.Log("Hammer Enter");

                HammerChildCollisionDetection hammerChild = other.GetComponent <HammerChildCollisionDetection> ();
                this.hammer = hammerChild.GetParentHammerObject();
                Charge(hammer.GetNumerator(), hammer.GetDenominator());
            }
        }
    }
Пример #10
0
 public void SetHammer(HammerObject hammer)
 {
     this.hammer = hammer;
 }