Ejemplo n.º 1
0
    public Sample8_3()
    {
        this.Text   = "サンプル";
        this.Paint += new PaintEventHandler(fm_Paint);

        ls = new List <MyBall>();

        Random rn = new Random();

        for (int i = 0; i < 30; i++)
        {
            MyBall bl = new MyBall();

            int x = rn.Next(this.Width);
            int y = rn.Next(this.Height);

            int r = rn.Next(256);
            int g = rn.Next(256);
            int b = rn.Next(256);

            Point p = new Point(x, y);
            Color c = Color.FromArgb(r, g, b);

            bl.Point = p;
            bl.Color = c;

            ls.Add(bl);
        }
    }
Ejemplo n.º 2
0
        private Node CreateBall(Vector3 pos)
        {
            var cmp = new MyBall ();

            var spr = new Sprite (Resource.GetTexture ("media/Earth-32x32.png"), 32, 32);

            var col = new SphereCollision (16);
            col.SetOffset (col.Radius, col.Radius, 0);

            var body = new PhysicsBody ();
            body.Type = ColliderType.Dynamic;
            body.SetShape (col);
            body.SetMaterial (new PhysicsMaterial ());
            body.ApplyForce (50000, 0, 0);

            var node = new Node ("Ball " + ballIndex++);
            node.Attach (spr);
            node.Attach (cmp);
            node.Attach (col);
            node.Attach (body);

            node.Translation = pos;

            return node;
        }
Ejemplo n.º 3
0
    public void InizializzaPalla(GameObject b)
    {
        MyBall myball = b.GetComponent <MyBall>();

        myball.velocity = Random.onUnitSphere * parameters.ballSpeed;

        myball.vy_0 = myball.velocity.y;
        myball.py_0 = b.transform.position.y;

        ScaleYDown(b);
    }
Ejemplo n.º 4
0
    public Sample8_4()
    {
        this.Text       = "サンプル";
        this.ClientSize = new Size(250, 200);

        bl = new MyBall();

        Point p = new Point(0, 0);
        Color c = Color.Blue;

        bl.Point = p;
        bl.Color = c;

        dx = 2;
        dy = 2;

        Timer tm = new Timer();

        tm.Interval = 100;
        tm.Start();

        this.Paint += new PaintEventHandler(fm_Paint);
        tm.Tick    += new EventHandler(tm_Tick);
    }
Ejemplo n.º 5
0
        private static bool RWillHit(AIHeroClient target)
        {
            if (MyBall == null || target.WillDie() || !target.IsKillable() || target.IsGapClosing() && !MyBall.IsInRange(target.GapCloseEndPos(), R.Range))
            {
                return(false);
            }

            if (target.IsCC())
            {
                return(true);
            }

            return(RPredHit(target) && RHit(target));
        }
Ejemplo n.º 6
0
    public void FixedUpdatePalla(GameObject b)
    {
        MyBall myball = b.GetComponent <MyBall>();


        float dist1 = Mathf.Round((parete1.transform.position.z - b.transform.position.z) * 1000) / 1000;
        float dist2 = Mathf.Round((b.transform.position.x - parete2.transform.position.x) * 1000) / 1000;
        float dist3 = Mathf.Round((b.transform.position.z - parete3.transform.position.z) * 1000) / 1000;
        float dist4 = Mathf.Round((parete4.transform.position.x - b.transform.position.x) * 1000) / 1000;
        float distp = Mathf.Round((b.transform.position.y - pavimento.transform.position.y) * 1000) / 1000;
        float dists = Mathf.Round((soffitto.transform.position.y - b.transform.position.y) * 1000) / 1000;


        if (dist1 <= parameters.ballSize / 2 & myball.velocity.z > 0)
        {
            myball.velocity.Scale(new Vector3(1.0f, 1.0f, -1.0f));
            counter++;
        }
        if (dist3 <= parameters.ballSize / 2 & myball.velocity.z < 0)
        {
            myball.velocity.Scale(new Vector3(1.0f, 1.0f, -1.0f));
            counter++;
        }
        if (dist4 <= parameters.ballSize / 2 & myball.velocity.x > 0)
        {
            myball.velocity.Scale(new Vector3(-1.0f, 1.0f, 1.0f));
            counter++;
        }
        if (dist2 <= parameters.ballSize / 2 & myball.velocity.x < 0)
        {
            myball.velocity.Scale(new Vector3(-1.0f, 1.0f, 1.0f));
            counter++;
        }
        if (dists <= parameters.ballSize / 2 & myball.velocity.y > 0)
        {
            myball.velocity.Scale(new Vector3(1.0f, -1.0f, 1.0f));
            counter++;
        }
        if (distp <= parameters.ballSize / 2 & myball.velocity.y < 0)
        {
            myball.velocity.Scale(new Vector3(1.0f, -1.0f, 1.0f));
            counter++;
        }

        foreach (GameObject p in ball)
        {
            if (Object.ReferenceEquals(b, p))
            {
                break;
            }

            Vector3 dist = b.transform.position - p.transform.position;

            if (Mathf.RoundToInt(dist.magnitude) <= parameters.ballSize & AvvicinamentoPalla(b, p))
            {
                Swap(ref myball.velocity, ref p.GetComponent <MyBall>().velocity);
                counter++;
            }
        }

        if (parameters.gravityValue != 0)
        {
            myball.velocity.z -= parameters.gravityValue * 9.8f * Time.deltaTime;
            myball.velocity   *= 1 - (myball.drag * Time.deltaTime);
        }

        Vector3 p_temp = b.transform.position + myball.velocity * Time.deltaTime;

        if (parete1.transform.position.z - p_temp.z < parameters.ballSize / 2)
        {
            p_temp.z = parete1.transform.position[2] - parameters.ballSize / 2;
        }
        if (p_temp.z - parete3.transform.position.z < parameters.ballSize / 2)
        {
            p_temp.z = parete3.transform.position[2] + parameters.ballSize / 2;
        }
        if (parete4.transform.position.x - p_temp.x < parameters.ballSize / 2)
        {
            p_temp.x = parete4.transform.position[0] - parameters.ballSize / 2;
        }
        if (p_temp.x - parete2.transform.position.x < parameters.ballSize / 2)
        {
            p_temp.x = parete2.transform.position[0] + parameters.ballSize / 2;
        }
        if (soffitto.transform.position.y - p_temp.y < parameters.ballSize / 2)
        {
            p_temp.y = soffitto.transform.position[1] - parameters.ballSize / 2;
        }
        if (p_temp.y - pavimento.transform.position.y < parameters.ballSize / 2)
        {
            p_temp.y = pavimento.transform.position[1] + parameters.ballSize / 2;
        }

        b.transform.position = p_temp;
    }