Exemple #1
0
        /// <summary>
        /// Called when either I, or a child of mine triggers with another object
        /// </summary>
        /// <param name="other"></param>
        void OnTriggerEnter(Collider other)
        {
            // do nothing if colliding with child object
            if (other.transform.IsChildOf(this.transform))
            {
                return;
            }

            // identify Other as deathball , and destroy player
            BouncingProjectile proj = other.GetComponent <BouncingProjectile>();

            if (proj != null)
            {
                if (photonView.isMine)
                {
                    Debug.Log(this.name + " has hit the ball, should I terminate?");

                    bool hitBoxEnabled = DebugGUI.GetInstance().GetPlayerHitBoxEnabled();

                    // kill self, send message to others that this player has died
                    if (hitBoxEnabled)
                    {
                        photonView.RPC("Kill", PhotonTargets.Others, null);
                        Kill();
                    }
                }
            }
        }
    static void DrawProjectileStatePoints(BouncingProjectile projectile , GizmoType gizmoType)
    {
        if (projectile == null)
            return;

        if (projectile.HasPackages() == false)
            return;

        List<Projectile2DState> points = projectile.GetAllPackages();

        DrawSegment(projectile.transform.position + Vector3.up * .99f, projectile.nextPosition + Vector3.up * .99f, Color.blue, visualizationTime);

        //Vector3 ballMoveDir = projectile.transform.position - projectile.previousPosition;

        for (int i = 0; i < points.Count; i++)
        {
            // draw little + for points
            DrawCross(points[i].Position3() + Vector3.up, .2f, Color.white, visualizationTime);

            // draw little -> for points
            Color targetColor = Color.yellow;
            if (points[i].ServerVerified == false)
                targetColor = Color.cyan;

            if (i != 0)
                DrawSegment(points[i].Position3() + Vector3.up * .9f, points[i - 1].Position3() + Vector3.up * .9f, Color.green, visualizationTime);

            DrawArrow(points[i].Position3() + Vector3.up, points[i].Direction3(), .5f, targetColor, visualizationTime);
        }

        

    }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        if (m_Deathball == null)
        {            // get deathball from game ( can be NULL )
            m_Deathball = GameObject.FindObjectOfType <BouncingProjectile>();
        }

        UpdatePositionField();
        UpdateDirectionField();
        UpdateSpeedField();
    }
Exemple #4
0
	// Update is called once per frame
	void Update () {
	
        if(m_Deathball == null)
        {            // get deathball from game ( can be NULL )
            m_Deathball = GameObject.FindObjectOfType<BouncingProjectile>();
        }

        UpdatePositionField();
        UpdateDirectionField();
        UpdateSpeedField();
    }
Exemple #5
0
    static void DrawProjectileStatePoints(BouncingProjectile projectile, GizmoType gizmoType)
    {
        if (projectile == null)
        {
            return;
        }

        if (projectile.HasPackages() == false)
        {
            return;
        }

        List <Projectile2DState> points = projectile.GetAllPackages();

        DrawSegment(projectile.transform.position + Vector3.up * .99f, projectile.nextPosition + Vector3.up * .99f, Color.blue, visualizationTime);

        //Vector3 ballMoveDir = projectile.transform.position - projectile.previousPosition;

        for (int i = 0; i < points.Count; i++)
        {
            // draw little + for points
            DrawCross(points[i].Position3() + Vector3.up, .2f, Color.white, visualizationTime);

            // draw little -> for points
            Color targetColor = Color.yellow;
            if (points[i].ServerVerified == false)
            {
                targetColor = Color.cyan;
            }

            if (i != 0)
            {
                DrawSegment(points[i].Position3() + Vector3.up * .9f, points[i - 1].Position3() + Vector3.up * .9f, Color.green, visualizationTime);
            }

            DrawArrow(points[i].Position3() + Vector3.up, points[i].Direction3(), .5f, targetColor, visualizationTime);
        }
    }
Exemple #6
0
        void OnTriggerEnter(Collider collider)
        {
            // let's see if a deathball has been hit
            BouncingProjectile dBall = collider.transform.GetComponent <BouncingProjectile>() as BouncingProjectile;

            if (dBall != null)
            {
                // some debug info
                //Debug.Log("WeaponCollisionManager has hit a ball. Telling ball to be Hit!");

                // a deathball was hit, change its direction and increase its speed
                Vector3 newDirection = (dBall.transform.position - m_Owner.transform.position);
                newDirection.y = 0f;// clamp y
                //dBall.DoBallHit(newDirection.normalized, collider.transform.position);
                dBall.photonView.RPC("BallHit", PhotonTargets.Others, new object[] { dBall.transform.position, newDirection, PhotonNetwork.time });
                dBall.BallHit(dBall.transform.position, newDirection, PhotonNetwork.time);
            }

            // see if a player was hit
            PlayerController hitplayer = collider.transform.GetComponent <PlayerController>() as PlayerController;

            if (hitplayer != null)
            {
                PlayerController owner = GetComponentInParent <PlayerController>() as PlayerController;
                if (owner == hitplayer)
                {
                    return;
                }
#if DEBUG
                Debug.Log(string.Format("Player {0} was hit by {1}", new object[] { hitplayer, owner }));
#endif

                // todo: channel this thorugh the player so I can adjust health, hatdrops and cancel attacks as well as network info
                Vector3 hitDir = collider.transform.position - owner.transform.position;
                hitplayer.Conditions.AddCondition(typeof(Condition_Knockback), GameTime.Instance.Time, new object[] { hitDir.normalized });
            }
        }