コード例 #1
0
    public override void Update(Blastball blastball)
    {
        //check collisions
        bool checkSphere = Physics.CheckSphere(blastball.transform.position, blastball.transform.lossyScale.x / 2, playerMask);

        Physics.OverlapSphereNonAlloc(blastball.transform.position, blastball.transform.lossyScale.x / 2, overlapPlayer, playerMask); //store the last player to have the blastball to prevent them from passing it to themselves
        //TODO: theoretically, there could be a *rare* bug if the ball collides with two players at the exact same time, so prioritize players of the same team as the thrower and then randomly pick between them, but doubtful this will happen often, if at all
        if (!oldCheckSphere && checkSphere && overlapPlayer[0] != oldPlayer)                                                          //check collision OnEnter and make sure the collision is with a new player
        {
            increment++;                                                                                                              //upon being passed, the blastball increments
            Debug.Log("incrementing");
            renderer.material.SetColor("_Color", Color.Lerp(minColor, maxColor, increment / Blastball.MaxIncrement));                 //lerp blastball color as it increments
            renderer.material.SetColor("_EmissionColor", Color.Lerp(minColor, maxColor, increment / Blastball.MaxIncrement));         //lerp blastball emission color as it increments
            blastball.transform.localScale = Vector3.Lerp(minSize, maxSize, increment / Blastball.MaxIncrement);                      //lerp blastball size as it increments
            rb.mass   = Mathf.Lerp(minMass, maxMass, increment / Blastball.MaxIncrement);
            oldPlayer = overlapPlayer[0];                                                                                             //set the player who has the ball as the old player
            Debug.Log(oldPlayer.gameObject);
        }
        oldCheckSphere = checkSphere;

        //change state
        if (increment >= Blastball.MaxIncrement)
        {
            blastball.ChangeState(blastball.stateBlastOnImpact);
        }
        else if (increment > oldIncrement)
        {
            blastball.ChangeState(blastball.stateIdle);
        }
    }
コード例 #2
0
 public override void Enter(Blastball blastball)
 {
     blastRadius    = 10f;
     blastMagnitude = 10f;
     blastLift      = 0f;
     goalMask       = LayerMask.GetMask("Goal");
     Debug.Log("ready to blast");
 }
コード例 #3
0
 public override void Enter(Blastball blastball)
 {
     rb         = blastball.GetComponent <Rigidbody>();
     playerMask = LayerMask.GetMask("Player");
     renderer   = blastball.GetComponent <Renderer>();
     minColor   = blastball.minColor;
     maxColor   = blastball.maxColor;
     minSize    = blastball.MinSizeVector;
     maxSize    = blastball.MaxSizeVector;
     minMass    = blastball.MinMass;
     maxMass    = blastball.MaxMass;
 }
コード例 #4
0
 public override void Update(Blastball blastball)
 {
     if (Physics.CheckSphere(blastball.transform.position, blastball.transform.lossyScale.x / 2, goalMask))
     {
         if (blastball.currentTeam == "Blue Team")
         {
             ScoreManager.blueScore++;
         }
         else if (blastball.currentTeam == "Blue Team")
         {
             ScoreManager.yellowScore++;
         }
         blastball.GetComponent <Ball>().Blast(blastball.transform.position, blastRadius, blastMagnitude, blastLift);
     }
 }
コード例 #5
0
 public override void Enter(Blastball blastball)
 {
 }
コード例 #6
0
 public override void Leave(Blastball blastball)
 {
 }
コード例 #7
0
 public override void Update(Blastball blastball)
 {
 }
コード例 #8
0
 public override void Leave(Blastball blastball)
 {
     oldIncrement = increment;
     Debug.Log(increment);
 }
コード例 #9
0
 public abstract void Leave(Blastball blastball);
コード例 #10
0
 public abstract void Update(Blastball blastball);
コード例 #11
0
 public abstract void Enter(Blastball blastball);