示例#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);
     }
 }
示例#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();
         }
     }
 }
 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");
 }
示例#4
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Trash")
     {
         Destroy(this.gameObject);
         if (!IsEat)
         {
             Game4Global.BrokeCombo();
         }
     }
 }
示例#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;
        }
示例#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;
         }
     }
 }
示例#7
0
 // Use this for initialization
 void Awake()
 {
     pGlobal = this;
 }