Ejemplo n.º 1
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Obstructcle")
     {
         //add force too gameObject and delete that item
         GameObject  gObj = col.gameObject;
         Obstructcle obs  = gObj.GetComponent <Obstructcle>();
         Vector2     diff = transform.position - gObj.transform.position;
         diff.y = 0;
         if (!IsBoost)
         {
             if (!IsStruggle)
             {
                 Damaged();
                 GameObject hpObj = GameObject.Instantiate(HPNortify) as GameObject;
                 hpObj.SetActive(true);
                 hpObj.transform.position = this.transform.position;
                 hpObj.GetComponent <HPNotification>().DecreaseLife(1);
                 Game4Global.BrokeCombo();
                 Game4Global.DecreaseLife();
             }
             GetComponent <Rigidbody2D>().velocity = Vector2.zero;
             GetComponent <Rigidbody2D>().AddForce(diff * 100);
         }
         else
         {
             GetComponent <Rigidbody2D>().velocity = Vector2.zero;
         }
         obs.Bounce(this.transform.position);
     }
 }
Ejemplo n.º 2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Star")
     {
         //GetScoreFromStar
         GameObject     gObj = other.gameObject;
         StarItemObject star = gObj.GetComponent <StarItemObject>();
         if (!star.IsEat)
         {
             int score = star.GetScore();
             star.Eat();
             Game4Global.AddScore(score);
             Game4Global.AddCombo();
             Game4_LvlingStat.AddEXP();
             //Eat Star
         }
     }
     if (other.tag == "Booster")
     {
         //Boost Speed
         GameObject  gObj  = other.gameObject;
         BoosterItem boost = gObj.GetComponent <BoosterItem>();
         if (!boost.IsEat)
         {
             Boost();
             boost.Eat();
         }
     }
 }
Ejemplo n.º 3
0
 public void SetGoldStar(float _timer)
 {
     lenPosition = this.transform.localPosition.x;
     IsGold      = true;
     timer       = _timer;
     //set house and choose house to throw this star
     Game4Global.ForceSpawnHouse(this);
     StopCoroutine("CountTimer");
     StartCoroutine("CountTimer");
 }
Ejemplo n.º 4
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Trash")
     {
         Destroy(this.gameObject);
         if (!IsEat)
         {
             Game4Global.BrokeCombo();
         }
     }
 }
Ejemplo n.º 5
0
        void FixedUpdate()
        {
            if (Game4Global.GetGameState() != GameState.GS_PLAY)
            {
                return;
            }
            //calculate roadSpeed
            roadSpeed     = TurtleCharacter.currentSpeed;
            roadPosition += roadSpeed / 60.0f;
            while (roadPosition > roadHeight / 100.0f)
            {
                roadPosition -= roadHeight / 100.0f;
            }

            roadVector.y = -roadPosition;
        }
Ejemplo n.º 6
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (Game4Global.GetGameState() != GameState.GS_PLAY)
     {
         return;
     }
     //add Velocity
     if (!IsStruggle)
     {
         currentSpeed += maxSpeed / 100.0f;
         if (!IsBoost)
         {
             if (currentSpeed > maxSpeed)
             {
                 currentSpeed = maxSpeed;
             }
         }
         else
         {
             currentSpeed = maxSpeed + Game4Global.pGlobal.BoosterSpeedPlus;
         }
     }
 }
Ejemplo n.º 7
0
 // Use this for initialization
 void Awake()
 {
     pGlobal = this;
 }