Пример #1
0
    public bool PickUpSmallPlayer()
    {
        //Can't pick up SmallPlayer unless your hands are free and you're not being carried
        bool handsFree = !HasBall && Above == null;

        if (!handsFree)
        {
            Debug.LogFormat("Failed to pick SmallPlayer up.  HasBall: {0}   Above != null: {1}", HasBall, Above != null);
            return(false);
        }

        //Check grab hitbox
        Collider[] hits = Physics.OverlapBox(grabHitbox.transform.TransformPoint(grabHitbox.center), grabHitbox.bounds.extents);
        foreach (Collider h in hits)
        {
            SmallPlayer other = h.GetComponent <SmallPlayer>();
            if (other != null && other.Team == Team && other.Below == null)
            {
                other.OnPickedUp(this);
                Above = other;
                Debug.LogFormat("{0} picked up {1}", transform.parent.name, other.transform.parent.name);
                return(true);
            }
        }

        Debug.Log("Nobody to pick up in grabHitbox");
        return(false);
    }
Пример #2
0
 // this function ensures that there is only ever one game controller
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Пример #3
0
 private void Awake()
 {
     scorer = GetComponent <SmallPlayer>();
 }