Exemple #1
0
 public bool JudgePlayerData(PFPlayer pfPlayerData)
 {
     //use this to judge if the pfPlayerData exists.
     if (pfPlayerData == null)
     {
         Debug.LogWarning("The " + pfPlayerData.GetComponentInParent <GameObject>().name + " doesn't have a PFPlayer.cs to record but still use a function in " + GetType().Name + ".cs. This will thus make the function failed.");
         return(false);
     }
     return(true);
 }
    //if something touches the dead area
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (!executable)
        {
            return;
        }
        GameObject objTouched = collision.gameObject;

        //judge if it is a player
        if (thePlatformerManager.JudgePlayer(objTouched))
        {
            PFPlayer player = objTouched.GetComponent <PFPlayer>();
            player.DeathAndRespawn(deadReason);
        }
        else
        {
            //not character... destroy it to save resource?
            Destroy(objTouched);
        }
    }
Exemple #3
0
    //just imagine that player touched this, it will temporarily lose control for a period.

    //if someone touches it
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (!executable)
        {
            return;
        }

        //judge if it is a player
        GameObject objTouched = collision.gameObject;

        if (thePlatformerManager.JudgePlayer(objTouched))
        {
            //here write down what happened.
            PFPlayer player = objTouched.GetComponent <PFPlayer>();
            if (totallyDeadly)
            {
                player.DeathAndRespawn(deadReason);
            }
            else
            {
                player.TakeDamage(damageWhenTouched, deadReason);
            }

            //freeze control
            objTouched.GetComponent <PF2DController>().FreezeControl(freezeTime);

            //push-Away effects
            if (pushAwaySpeed > 0f)
            {
                PushAwayWithSpeed(objTouched, pushAwaySpeed);
                Debug.Log("hi");
                return;
            }
            PushAway(objTouched, pushAwayForces);
        }
        else
        {
            //not character... destroy it to save resource?
            //Destroy(other.gameObject);
        }
    }