コード例 #1
0
ファイル: Ball.cs プロジェクト: murrrkle/bci-game-jam2019
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(rb.velocity.magnitude);
        //Debug.Log(rb.velocity.magnitude);
        if (rb.velocity.magnitude <= DespawnThreshold) // Stop Ball if velocity is lower than Threshold.
        {
            rb.velocity = Vector3.zero;

            // DESPAWN THE BALL, UPDATE LEVEL CONTROLLER

            lc.DecreaseBalls();
        }

        else if (rb.velocity.magnitude >= 50)
        {
            rb.velocity = rb.velocity.normalized * 50;
        }

        Vector3 curPos = transform.position;

        if (Vector3.Distance(oldPos, curPos) >= SplatDistanceThreshold && SplatColour >= 0)
        {
            Splatter splat = (Splatter)Instantiate(splatter, transform.position, Quaternion.identity);
            splat.transform.parent = GameObject.Find("SplatTrail").transform;

            //spawns the splatter
            splat.GetComponent <Splatter>().splatColour = SplatColour; //set the splatter color
            splat.GetComponent <Splatter>().randomColor = false;       //make random false as we want the splatter color to the color we assigned
            splat.GetComponent <Splatter>().ApplyStyle();              //then apply the style

            oldPos = curPos;
        }
    }
コード例 #2
0
ファイル: Ball.cs プロジェクト: YashJaveri/ColorSplash-Game
    public void SplateColor()
    {
        Splatter splatterObj = (Splatter)Instantiate(Splatter, transform.position, Quaternion.identity);

        splatterObj.GetComponent <Splatter>().splatColor  = ColorBall;
        splatterObj.GetComponent <Splatter>().randomColor = false;
        splatterObj.GetComponent <Splatter>().ApplyStyle();
    }
コード例 #3
0
 //detects the collider with specific tags
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Colors"))
     {
         //get the collided object color
         Color objCol = other.GetComponent <SpriteRenderer>().color;
         //spawns the splatter
         Splatter splatterObj = (Splatter)Instantiate(splatter, other.transform.position, Quaternion.identity);
         splatterObj.GetComponent <Splatter>().splatColor  = objCol; //set the splatter color
         splatterObj.GetComponent <Splatter>().randomColor = false;  //make random false as we want the splatter color to the color we assigned
         splatterObj.GetComponent <Splatter>().ApplyStyle();         //then apply the style
     }
 }
コード例 #4
0
    public void Splatt(Vector3 Position, Collider2D other)
    {
        if (other.tag == "Enemy")
        {
            Debug.Log("ENEMY");
            Splatter splat = Instantiate(DynamicSplatter, Position, Quaternion.identity);
            float    scale = Random.Range(2f, 3f);
            splat.transform.localScale = new Vector3(scale, scale, scale);
            splat.transform.SetParent(other.gameObject.transform, true);
            splat.GetComponent <SpriteRenderer>().sortingOrder = -1;
        }

        RaycastHit2D hit = Physics2D.CircleCast(Position, 3, Vector2.up, Mathf.Infinity, CollisionLayer);

        if (hit)
        {
            int k = Random.Range(2, 4);
            for (int i = 0; i < k; i++)
            {
                Instantiate(_splatter, Position + new Vector3(Random.Range(0, 1), 0, 0), Quaternion.identity);
            }
        }
    }