public static int GetExcerciseScore()
    {
        int       combo           = Game2Global.GetCombo();
        PigLvling gameLvl         = GameLvlingObject.PigLvlList[currentLevel];
        float     scoreMultiplier = (1 + (gameLvl.ExcerciseModifier * combo));

        return((int)(10000 * scoreMultiplier));
    }
示例#2
0
    public void CreatePackage()
    {
        IsFree = false;
        PigLvling currentLvl = Game2_LvlingStat.GetLvling();

        extraToken = Game2Global.GetExtraToken();
        gda.SetTagFlag(Game2Global.GetRandomPackageFlag(extraToken + 1));
        package.SetPackageIndex(Random.Range(0, 5));
    }
示例#3
0
    IEnumerator EatPackage()
    {
        Vector3 eatPosition = Game2Global.GetEatingPoint();

        while (Vector3.Distance(transform.position, eatPosition) > 0.4f)
        {
            transform.position = Vector3.Lerp(transform.position, eatPosition, Time.deltaTime * 5);
            yield return(null);
        }
        Destroy(this.gameObject);
        yield return(null);
    }
示例#4
0
 // Update is called once per frame
 void Update()
 {
     if (IsSick)
     {
         Animator anim = GetComponent <Animator> ();
         if (anim.GetCurrentAnimatorStateInfo(0).IsName("PigIdle"))
         {
             IsSick = false;
             Game2Global.SetSick(false);
         }
     }
 }
示例#5
0
    public void Sick()
    {
        Animator anim = GetComponent <Animator> ();

        anim.Play("PigSick", -1, 0.0f);
        GetComponent <AudioSource>().PlayOneShot(SickSound);
        Game2Global.SetSick(true);
        GameObject hpObj = GameObject.Instantiate(HPNortify) as GameObject;

        hpObj.SetActive(true);
        hpObj.transform.position = this.transform.position;
        hpObj.GetComponent <HPNotification>().DecreaseLife(1);
        IsSick = true;
    }
示例#6
0
    void DropToTrash()
    {
        IsTouchable = false;
        IsFree      = true;
        Game2Global.Spawning();
        //release package
        package.transform.parent = null;
        package.GetComponent <Renderer>().sortingOrder = -5;
        package.gameObject.AddComponent <Rigidbody2D>();
        package.GetComponent <Rigidbody2D>().gravityScale = 1.0f;
//		foodList.Remove(this);
        Game2Global.ReturnFlag(gda.GDAFlag);
        Game2Global.ReturnExtraToken(extraToken);
        if ((gda != null) && (gda.gameObject != null))
        {
            Destroy(gda.gameObject);
        }
        IsMoving = true;
    }
示例#7
0
 void PigEating()
 {
     IsTouchable = false;
     IsFree      = true;
     Game2Global.Spawning();
     //release package
     package.transform.parent = null;
     package.GetComponent <Renderer>().sortingOrder = -5;
     //		foodList.Remove(this);
     Game2Global.PigEating(gda.GDAFlag);
     Game2Global.ReturnFlag(gda.GDAFlag);
     Game2Global.ReturnExtraToken(extraToken);
     if ((gda != null) && (gda.gameObject != null))
     {
         Destroy(gda.gameObject);
     }
     //play package move to Position
     package.Eat();
     IsMoving = true;
 }
示例#8
0
 // Update is called once per frame
 void Update()
 {
     if (Game2Global.GlobalPause)
     {
         return;
     }
     if (sick)
     {
         return;
     }
     if (!IsGamePlay)
     {
         return;
     }
     currentTimer -= Time.deltaTime;
     if (currentTimer < 0)
     {
         //pig Angry
         Game2Global.PigAngry();
         currentTimer = timer;
     }
     percent = currentTimer * 100 / timer;
     SetProgress(percent);
 }
示例#9
0
 // Use this for initialization
 void Awake()
 {
     pGlobal = this;
 }
示例#10
0
    // Update is called once per frame
    void Update()
    {
        if (Game2Global.GlobalPause)
        {
            GetComponent <Rigidbody2D>().Sleep();
            return;
        }
        else
        {
            GetComponent <Rigidbody2D>().WakeUp();
        }
        Animator anim = GetComponent <Animator> ();

        if (IsMoving)
        {
            anim.SetBool("IsMoving", true);
            //movingspeed increase
            if (foodList [0] == this)
            {
                movingSpeed += 0.01f;
                if (movingSpeed > 1.0f)
                {
                    movingSpeed = 1.0f;
                }
            }
            if (MovingRight)
            {
                anim.SetBool("MovingRight", true);
                GetComponent <Rigidbody2D>().velocity = new Vector2(movingSpeed * 60, 0);
            }
            else
            {
                anim.SetBool("MovingRight", false);
                GetComponent <Rigidbody2D>().velocity = new Vector2(-movingSpeed * 60, 0);
            }
        }
        else
        {
            anim.SetBool("IsMoving", false);
            movingSpeed = 0;
            GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0);
        }

#if UNITY_EDITOR || UNITY_WEBPLAYER
        if (!IsDrag && IsTouchable)
        {
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                //drop trash
                IsDrag = true;
                DropToTrash();
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                IsDrag = true;
                PigEating();
            }
        }
        if (Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow))
        {
            IsDrag = false;
        }
#endif
        bool    TouchDown = TouchInterface.GetTouchDown();
        bool    TouchUp   = TouchInterface.GetTouchUp();
        Vector2 pos       = TouchInterface.GetTouchPosition();
        if (TouchDown)
        {
            if (IsTouchable && package.GetComponent <Collider2D>().OverlapPoint(pos))
            {
                IsDrag  = true;
                DragPos = pos;
            }
        }
        else if (TouchUp)
        {
            IsDrag = false;
        }
        else
        {
            if (IsDrag)
            {
                //check pos
                if (((pos.x - DragPos.x) > 0.5f) && !Game2Global.PigIsSick())
                {
                    IsDrag = false;
                    PigEating();
                }
                else if ((DragPos.y - pos.y) > 0.5f)
                {
                    IsDrag = false;
                    DropToTrash();
                }
                else if ((DragPos.x - pos.x > 0.5f))
                {
                    IsDrag = false;
                    DropToTrash();
                }
            }
        }
    }