Example #1
0
        protected override void Setup()
        {
            base.Setup();

            if (Instance == null)
            {
                Instance = this;
            }

            this.KeyPress += PongPaddleView_KeyPress;
            int shapeSize       = Math.Min(this.Width, this.Height);
            int shapeSizeThird  = shapeSize / 3;
            int strokeWidth     = 10;
            int strokeWidthHalf = strokeWidth / 2;

            // setup details on paint used for arc
            _paintArc.SetStyle(Paint.Style.Stroke);
            _paintArc.StrokeWidth = strokeWidth;
            // setup details on paint used for rect
            _paintRect.SetStyle(Paint.Style.Fill);
            // setup details on paint used for rect
            _paintDebug.SetStyle(Paint.Style.Stroke);


            Path pathArc = new Path();

            // add the arc slightly smaller then the drawable size will be to prevent clipping
            pathArc.AddArc(0, 0, shapeSize - strokeWidthHalf, shapeSize - strokeWidthHalf, 75, 30);
            _drawableArc.Shape = new PathShape(pathArc, shapeSize, shapeSize);
            _drawableArc.Paint.Set(_paintArc);

            // set collision bounds
            pathArc.ComputeBounds(CollisionBounds, true);
            CollisionBounds.Inset(-strokeWidthHalf, -strokeWidthHalf);

            RectF arcBounds = new RectF();

            pathArc.ComputeBounds(arcBounds, true);
            arcBounds.Top    -= strokeWidthHalf;
            arcBounds.Bottom -= strokeWidthHalf;

            Path pathRect = new Path();

            pathRect.AddRect(arcBounds, Path.Direction.Cw);
            _drawableRect.Shape = new PathShape(pathRect, shapeSize, shapeSize);
            _drawableRect.Paint.Set(_paintRect);

            // setup debug drawable
            pathArc.ComputeBounds(arcBounds, true);
            arcBounds.Inset(-strokeWidthHalf, -strokeWidthHalf);
            arcBounds.Bottom -= strokeWidthHalf;
            Path pathDebug = new Path();

            pathDebug.AddRect(arcBounds, Path.Direction.Cw);
            _drawableDebug.Shape = new PathShape(pathDebug, shapeSize, shapeSize);
            _drawableDebug.Paint.Set(_paintDebug);
        }
Example #2
0
        public override bool VerifyCollision(ITouchable other)
        {
            var colliding = CollisionBounds.IntersectsWith(other.CollisionBounds);

            if (!(other is Shape) && colliding)
            {
                this.colliding = true;
            }
            return(colliding);
        }
    // START
    void Start()
    {
        spriteRenderer = GetComponent <SpriteRenderer>();
        rb             = GetComponent <Rigidbody2D>();
        gravity        = GetComponent <GravityController>();

        Bounds spriteBounds = spriteRenderer.sprite.bounds;

        bounds = new CollisionBounds(spriteBounds, gameObject, boundsScale, boundsOffset);
    }
Example #4
0
 public bool VerifyCollision(ITouchable other)
 {
     if (other is Shoot shoot)
     {
         if (shoot.Cannon.Support == this)
         {
             return(false);
         }
     }
     return(CollisionBounds.IntersectsWith(other.CollisionBounds));
 }
Example #5
0
        public override bool VerifyCollision(ITouchable other)
        {
            var colliding = CollisionBounds.IntersectsWith(other.CollisionBounds);

            if (!(other is Block) && colliding)
            {
                return(this.colliding = true);
            }
            else
            {
                return(colliding);
            }
        }
Example #6
0
        private void UpdateFormTitle()
        {
            string fn = CollisionBounds?.GetTitle() ?? "untitled";

            Text = fn + ((CollisionBounds?.HasChanged ?? false) ? "*" : "");
        }
Example #7
0
 public override bool VerifyCollision(ITouchable other)
 {
     return(CollisionBounds.IntersectsWith(other.CollisionBounds));
 }
Example #8
0
        public string GetFullNameString(string defval)
        {
            string name = defval;

            if (MultipleSelection)
            {
                name = "Multiple items";
            }
            else if (EntityDef != null)
            {
                name = EntityDef._CEntityDef.archetypeName.ToString();
            }
            else if (Archetype != null)
            {
                name = Archetype.Hash.ToString();
            }
            else if (CollisionBounds != null)
            {
                name = CollisionBounds.GetName();
            }
            if (Geometry != null)
            {
                name += " (" + GeometryIndex.ToString() + ")";
            }
            if (TimeCycleModifier != null)
            {
                name = TimeCycleModifier.CTimeCycleModifier.name.ToString();
            }
            if (BoxOccluder != null)
            {
                name = "BoxOccluder " + (BoxOccluder.Ymap?.Name ?? "") + ": " + BoxOccluder.Index.ToString();
            }
            if (OccludeModel != null)
            {
                name = "OccludeModel " + (OccludeModel.Ymap?.Name ?? "") + ": " + OccludeModel.Index.ToString();
            }
            if (CarGenerator != null)
            {
                name = CarGenerator.NameString();
            }
            if (EntityExtension != null)
            {
                name += ": " + EntityExtension.Name;
            }
            if (ArchetypeExtension != null)
            {
                name += ": " + ArchetypeExtension.Name;
            }
            if (WaterQuad != null)
            {
                name = "WaterQuad " + WaterQuad.ToString();
            }
            if (NavPoly != null)
            {
                name = "NavPoly " + NavPoly.ToString();
            }
            if (NavPoint != null)
            {
                name = "NavPoint " + NavPoint.ToString();
            }
            if (NavPortal != null)
            {
                name = "NavPortal " + NavPortal.ToString();
            }
            if (PathNode != null)
            {
                name = "PathNode " + PathNode.AreaID.ToString() + "." + PathNode.NodeID.ToString();// + FloatUtil.GetVector3String(PathNode.Position);
            }
            if (TrainTrackNode != null)
            {
                name = "TrainTrackNode " + FloatUtil.GetVector3String(TrainTrackNode.Position);
            }
            if (ScenarioNode != null)
            {
                name = ScenarioNode.ToString();
            }
            if (Audio != null)
            {
                name = Audio.ShortTypeName + " " + Audio.GetNameString();//  + FloatUtil.GetVector3String(Audio.InnerPos);
            }
            if (MloRoomDef != null)
            {
                name = "MloRoomDef " + MloRoomDef.RoomName;
            }
            return(name);
        }
Example #9
0
    public void Transform(float X, float Y, float Z)
    {
        if (collisionTree.Count < 1)
        {
            testCollision(0, 0, 0);
        }
        translation = new Vector3(X, Y, Z);
        return;
        float x = X;
        float y = Y;
        float z = Z;
        //TODO: Somehow update collisiontree
        //return;
        if (origtree == null)
        {
            origtree = new CollisionBounds[collisionTree.Count];
            for (int i = 0; i < origtree.Length; i++)
            {
                origtree[i] = new CollisionBounds(null, null);
            }
            for (int i = 0; i < origtree.Length; i++)
            {
                List<ObjVertex> vt = new List<ObjVertex>();
                foreach (ObjVertex et in collisionTree[i].Key)
                {
                    vt.Add(new ObjVertex() { Vertex = et.Vertex });

                }
                origtree[i].Key = vt.ToArray();
                float[] data = new float[collisionTree[i].Value.Length];
                Buffer.BlockCopy(collisionTree[i].Value, 0, data, 0, data.Length * sizeof(float));
                origtree[i].Value = data;

            }
        }
        CollisionBounds[] tempray = new CollisionBounds[origtree.Length];

        for (int i = 0; i < origtree.Length; i++)
        {
            tempray[i] = new CollisionBounds(null, null);
        }
        for (int i = 0; i < origtree.Length; i++)
        {
            List<ObjVertex> vt = new List<ObjVertex>();
            foreach (ObjVertex et in origtree[i].Key)
            {
                vt.Add(new ObjVertex() { Vertex = et.Vertex });

            }
            tempray[i].Key = vt.ToArray();
            float[] data = new float[origtree[i].Value.Length];
            Buffer.BlockCopy(origtree[i].Value, 0, data, 0, data.Length * sizeof(float));
            tempray[i].Value = data;

        }
        collisionTree = new List<CollisionBounds>(tempray);

        foreach (CollisionBounds et in collisionTree)
        {
            foreach (ObjVertex ett in et.Key)
            {
                ett.Vertex.X -= x;
                ett.Vertex.Y -= y;
                ett.Vertex.Z -= z;
            }
            et.Value[0] -= x;
            et.Value[1] -= y;
            et.Value[2] -= z;
            et.Value[3] -= x;
            et.Value[4] -= y;
            et.Value[5] -= z;

        }
        return;
        Vector3 transformation = new Vector3(x,y,z);
        foreach(ObjQuad e in quads) {
        ObjVertex vertex = vertices[e.Index0];
            vertex.Vertex.X+=transformation.X;
            vertex.Vertex.Y+=transformation.Y;
            vertex.Vertex.Z+=transformation.Z;
            vertices[e.Index0] = vertex;
            vertex = vertices[e.Index1];
            vertex.Vertex.X+=transformation.X;
            vertex.Vertex.Y+=transformation.Y;
            vertex.Vertex.Z+=transformation.Z;
            vertices[e.Index1] = vertex;
            vertex = vertices[e.Index2];
            vertex.Vertex.X+=transformation.X;
            vertex.Vertex.Y+=transformation.Y;
            vertex.Vertex.Z+=transformation.Z;
            vertices[e.Index2] = vertex;
            vertex = vertices[e.Index3];
            vertex.Vertex.X+=transformation.X;
            vertex.Vertex.Y+=transformation.Y;
            vertex.Vertex.Z+=transformation.Z;
            vertices[e.Index3] = vertex;
        }
        foreach(ObjTriangle e in triangles) {
        ObjVertex vertex = vertices[e.Index0];
            vertex.Vertex.X+=transformation.X;
            vertex.Vertex.Y+=transformation.Y;
            vertex.Vertex.Z+=transformation.Z;
            vertex = vertices[e.Index1];
            vertex.Vertex.X+=transformation.X;
            vertex.Vertex.Y+=transformation.Y;
            vertex.Vertex.Z+=transformation.Z;
            vertex = vertices[e.Index2];
            vertex.Vertex.X+=transformation.X;
            vertex.Vertex.Y+=transformation.Y;
            vertex.Vertex.Z+=transformation.Z;
        }
    }
Example #10
0
        public string GetNameString(string defval)
        {
            string name = defval;

            if (MultipleSelection)
            {
                name = "Multiple items";
            }
            else if (EntityDef != null)
            {
                name = EntityDef.CEntityDef.archetypeName.ToString();
            }
            else if (Archetype != null)
            {
                name = Archetype.Hash.ToString();
            }
            else if (TimeCycleModifier != null)
            {
                name = TimeCycleModifier.CTimeCycleModifier.name.ToString();
            }
            else if (CarGenerator != null)
            {
                name = CarGenerator.CCarGen.carModel.ToString();
            }
            else if (DistantLodLights != null)
            {
                name = DistantLodLights.Ymap?.Name ?? "";
            }
            else if (CollisionBounds != null)
            {
                name = CollisionBounds.GetName();
            }
            if (EntityExtension != null)
            {
                name = EntityExtension.Name;
            }
            if (ArchetypeExtension != null)
            {
                name = ArchetypeExtension.Name;
            }
            if (WaterQuad != null)
            {
                name = "WaterQuad " + WaterQuad.ToString();
            }
            if (NavPoly != null)
            {
                name = "NavPoly " + NavPoly.ToString();
            }
            if (NavPoint != null)
            {
                name = "NavPoint " + NavPoint.ToString();
            }
            if (NavPortal != null)
            {
                name = "NavPortal " + NavPortal.ToString();
            }
            if (PathNode != null)
            {
                name = "PathNode " + PathNode.AreaID.ToString() + "." + PathNode.NodeID.ToString(); //+ FloatUtil.GetVector3String(PathNode.Position);
            }
            if (TrainTrackNode != null)
            {
                name = "TrainTrackNode " + FloatUtil.GetVector3String(TrainTrackNode.Position);
            }
            if (ScenarioNode != null)
            {
                name = ScenarioNode.ToString();
            }
            if (Audio != null)
            {
                name = Audio.ShortTypeName + " " + Audio.GetNameString();// FloatUtil.GetVector3String(Audio.InnerPos);
            }
            if (MloRoomDef != null)
            {
                name = "MloRoomDef " + MloRoomDef.RoomName;
            }
            return(name);
        }
Example #11
0
 /// <summary>
 ///     Kolize s obdelnikem
 /// </summary>
 /// <param name="rectangle">
 ///     Bounding box objektu se kterym se kontroluje kolize
 /// </param>
 /// <returns></returns>
 public virtual bool RectIntersects(Rect rectangle)
 {
     return(CollisionBounds.IntersectsWith(rectangle));
 }
Example #12
0
 /// <summary>
 ///     Kontrola jestli doslo ke kolizi
 /// </summary>
 /// <param name="gameObject">
 ///     Objekt se kterym doslo ke kolizi
 /// </param>
 /// <returns></returns>
 public virtual bool Intersects(IGameObject gameObject)
 {
     return(CollisionBounds.IntersectsWith(gameObject.CollisionBounds));
 }