Beispiel #1
0
 public CollisionComponent(CollisionArea area, bool pixelPerfect, bool collider)
 {
     CollisionArea = area;
     PixelPerfect  = pixelPerfect;
     Collider      = collider;
     Active        = true;
 }
        //TODO: This is supposed to be an entire modification system, not just ignoreArea stuff
        private void ModifyProjectile(AteObject firer, Projectile newProjectile)
        {
            CollisionArea projectileArea = newProjectile.GetComponent <CollisionArea> () as CollisionArea;

            if (projectileArea == null)
            {
                return;
            }

            CollisionArea firerArea = firer.GetComponent <CollisionArea> () as CollisionArea;

            if (firerArea == null)
            {
                return;
            }

            projectileArea.SetColliderIgnoreArea(firerArea);
        }
Beispiel #3
0
    void OnDrawGizmos()
    {
        Quaternion originalRotation = transform.rotation;

        for (int i = 0; i < collisionAreas.Count; i++)
        {
            CollisionArea collisionArea = collisionAreas[i];
            if (collisionArea.show)
            {
                collisionArea.rotation.eulerAngles = collisionArea.rotationEuler;
                transform.rotation *= collisionArea.rotation;
                Gizmos.matrix       = transform.localToWorldMatrix;
                Gizmos.DrawFrustum(Vector3.zero, collisionArea.height, 3, 0, collisionArea.width / collisionArea.height);

                transform.rotation = originalRotation;
            }
        }
    }
Beispiel #4
0
    public void SetupVehicleManager()
    {
        //   Debug.LogWarning("Vehicle Health Manager has not been fully ported to the new PhysX system");
        gamestateTracker           = FindObjectOfType <GamestateTracker>();
        gamestateTrackerPhotonView = gamestateTracker.GetComponent <PhotonView>();
        networkManager             = FindObjectOfType <NetworkManager>();
        maxHealth        = health;
        rb               = GetComponent <PhysXRigidBody>();
        icd              = GetComponent <InterfaceCarDrive>();
        icd4             = GetComponent <InterfaceCarDrive4W>();
        carDriver        = icd.GetComponent <IDrivable>();
        inputDriver      = GetComponent <InputDriver>();
        myPhotonView     = GetComponent <PhotonView>();
        npv              = GetComponent <NetworkPlayerVehicle>();
        announcerManager = FindObjectOfType <AnnouncerManager>();



        _rammingDetails = new Weapon.WeaponDamageDetails(null, 0, 0, Weapon.DamageType.ramming, 0, Vector3.zero);

        for (int i = 0; i < collisionAreas.Count; i++)
        {
            CollisionArea collisionArea = collisionAreas[i];
            collisionArea.rotation.eulerAngles = collisionArea.rotationEuler;
            collisionAreas[i] = collisionArea;
        }

        defaultDrag            = rb.linearDamping;
        defaultAngularDrag     = rb.angularDamping;
        playerTransformTracker = FindObjectOfType <PlayerTransformTracker>();

        PlayerEntry player = gamestateTracker.players.Get((short)PhotonNetwork.LocalPlayer.ActorNumber);

        if (player.teamId == teamId)
        {
            tutorials.SetActive(true);
        }
        else
        {
            tutorials.SetActive(false);
        }
        player.Release();
    }
Beispiel #5
0
        public override void DrawInspector()
        {
            base.DrawInspector();

            bool drawList_triggeredByTypes = true;

            EditorHelper.DrawResizableList <GOType>
                ("Triggered by Specific Types", ref drawList_triggeredByTypes, ref triggeredByTypes, DrawEntry_TriggeredByType);

            if (triggeredByTypes.Count <= 0)
            {
                EditorGUILayout.LabelField("Leave empty to be triggered by all types.");
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            areaType = (AreaType)EditorGUILayout.EnumPopup("Triggered Using Area Type", areaType);
            if (areaType.Equals(AreaType.CollisionArea))
            {
                EditorGUI.indentLevel++;
                collisionArea = EditorGUILayout.ObjectField("Collision Area", collisionArea, typeof(CollisionArea), true) as CollisionArea;
                EditorGUI.indentLevel--;
            }

            requiredToInteract = EditorGUILayout.IntField("Required to Interact", requiredToInteract);
            eventsToInteract   = (EventType_UI)EditorGUILayout.EnumPopup("Event to Interact", eventsToInteract);
            interactKey        = (KeyCode)EditorGUILayout.EnumPopup("Interact Key", interactKey);

            bool drawList_behavioursOnEnter    = true;
            bool drawList_behavioursOnInteract = true;
            bool drawList_behavioursOnExit     = true;

            EditorHelper.DrawResizableList <TriggeredBehaviour>
                ("Behaviours on Entry", ref drawList_behavioursOnEnter, ref behavioursOnEnter, DrawEntry_BehaviourOnEnter);
            EditorHelper.DrawResizableList <TriggeredBehaviour>
                ("Behaviours on Interact", ref drawList_behavioursOnInteract, ref behavioursOnInteract, DrawEntry_BehaviourOnInteract);
            EditorHelper.DrawResizableList <TriggeredBehaviour>
                ("Behaviours on Exit", ref drawList_behavioursOnExit, ref behavioursOnExit, DrawEntry_BehaviourOnExit);
        }
        public bool IntersectPixel(CollisionArea target, Texture2D targetTex, Texture2D sourceTex)
        {
            Color[] sourceTexColor = new Color[sourceTex.Width * sourceTex.Height];
            Color[] targetTexColor = new Color[targetTex.Width * targetTex.Height];
            sourceTex.GetData <Color>(sourceTexColor);
            targetTex.GetData <Color>(targetTexColor);

            Rectangle targetRect = ((CollisionRectangle)target).source;
            Rectangle its        = Rectangle.Intersect(source, targetRect);

            for (int y = its.Top; y < its.Bottom; ++y)
            {
                for (int x = its.Left; x < its.Right; ++x)
                {
                    Color colorSource = sourceTexColor[(x - source.Left) + (y - source.Top) * source.Width];
                    Color colorTarget = targetTexColor[(x - targetRect.Left) + (y - targetRect.Top) * targetRect.Width];
                    if (colorSource.A != 0 && colorTarget.A != 0)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        // Controls if the robot is heading towards a collision area, used by FIFO
        public static bool isAtHeading(CollisionArea area, DoublePoint robotPosition, DoublePoint robotHeading)
        {
            DoublePoint corner1, corner2;

            if (robotPosition.X > area.getX())
            {
                if (robotPosition.X > area.getRight())
                {
                    if (robotPosition.Y > area.getBottom())
                    {
                        corner1 = area.getPoint(4);
                        corner2 = area.getPoint(12);
                    }
                    else if (robotPosition.Y < area.getY())
                    {
                        corner1 = area.getPoint(8);
                        corner2 = area.getPoint(0);
                    }
                    else
                    {
                        corner1 = area.getPoint(8);
                        corner2 = area.getPoint(12);
                    }
                }
                else
                {
                    if (robotPosition.Y > area.getBottom())
                    {
                        corner1 = area.getPoint(4);
                        corner2 = area.getPoint(8);
                    }
                    else
                    {
                        corner1 = area.getPoint(12);
                        corner2 = area.getPoint(0);
                    }
                }
            }
            else
            {
                if (robotPosition.Y > area.getBottom())
                {
                    corner1 = area.getPoint(8);
                    corner2 = area.getPoint(0);
                }
                else if (robotPosition.Y < area.getY())
                {
                    corner1 = area.getPoint(4);
                    corner2 = area.getPoint(12);
                }
                else
                {
                    corner1 = area.getPoint(4);
                    corner2 = area.getPoint(0);
                }
            }

            //Largest angle
            DoublePoint corner1Heading = new DoublePoint(corner1.X - robotPosition.X, corner1.Y - robotPosition.Y);
            //Smallest angle
            DoublePoint corner2Heading = new DoublePoint(corner2.X - robotPosition.X, corner2.Y - robotPosition.Y);
            double      cornerAngDiff  = Math.Abs(angleDifferance(corner1Heading, corner2Heading));
            double      corner1AngDiff = Math.Abs(angleDifferance(robotHeading, corner1Heading));
            double      corner2AngDiff = Math.Abs(angleDifferance(robotHeading, corner2Heading));

            area.setHeadingEdges(corner1, corner2);

            if (cornerAngDiff > corner1AngDiff && cornerAngDiff > corner2AngDiff && (corner1AngDiff + corner2AngDiff) < PI)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public bool Intersect(CollisionArea target)
 {
     return(source.Intersects(((CollisionRectangle)target).source));
 }