コード例 #1
0
ファイル: Objects.cs プロジェクト: jazzyjester/Mario-Game
 public Collision(Rectangle S,Rectangle D,CollisionType T,CollisionDirection Di)
 {
     Src = S;
     Dest = D;
     Type = T;
     Dir = Di;
 }
コード例 #2
0
ファイル: WorldBounds.cs プロジェクト: tavoe/blocker
    //This toggles if the world bounds are a sphere or a rectangle.
    void setCollisionType(CollisionType ct)
    {
        // mutate dat shit
        collisionType = ct;

        // remove any collider currently on the worldbounds.
        Destroy (gameObject.GetComponent<BoxCollider>());
        Destroy (gameObject.GetComponent<SphereCollider>());

        // based on the collisionType variable, add a new collider with some default
        // parameters.
        switch(collisionType)
        {
        case CollisionType.Sphere:
            collScript = this.gameObject.AddComponent<SphereCollider>();
            collScript.isTrigger = true;
            setScale(500, 0, 0);
            break;
        case CollisionType.Box:
            collScript = this.gameObject.AddComponent<BoxCollider>();
            collScript.isTrigger = true;
            setScale (1000,1000, 1000);
            break;
        }
    }
コード例 #3
0
ファイル: Map.cs プロジェクト: thestonefox/XNA-Alien-Lander
 public CollisionType CheckBuildingCollision(Base3DObject bob)
 {
     //3 types of collision: no collision, crash and landing
     ct = CollisionType.None;
     for (int c = 0; c < blocks.Length; c++)
     {
         if (blocks[c].Collided(bob))
         {
             blocks[c].HitTest = true;
             bob.HitTest = true;
             ct = CollisionType.Building;
             if (bob.Bounds.Min.Y > (blocks[c].Bounds.Max.Y - playerSafeZones.Y) && (bob.Bounds.Min.X > blocks[c].Bounds.Min.X + playerSafeZones.X && bob.Bounds.Max.X < blocks[c].Bounds.Max.X - playerSafeZones.X && bob.Bounds.Min.Z > blocks[c].Bounds.Min.Z + playerSafeZones.Z && bob.Bounds.Max.Z < blocks[c].Bounds.Max.Z - playerSafeZones.Z))
             {
                 ct = CollisionType.Roof;
             }
             break;
         }
         else
         {
             blocks[c].HitTest = false;
             bob.HitTest = false;
         }
     }
     return ct;
 }
コード例 #4
0
        private float ReleaseTime;  //tmp ?


        public SimpleButton(Vector2 position, Vector2 size, float reltime = 0.3f, CollisionType ctype = CollisionType.Rectangle, Texture2D textureoff = null, Texture2D textureon = null)
        {
            Position = position;
            Size = size;
            ReleasedTexture = textureoff;
            PressedTexture = textureon;

			// button area is set whatever collision type because it is also use for drawing

			if (ctype == CollisionType.Rectangle)
			{
				ButtonArea = new Rectangle((int)position.X, (int)position.Y, (int)Size.X, (int)size.Y);
				collisionType = CollisionType.Rectangle;
			}
			else
			{
				ButtonAreaCircle = new Circle(Size.X /2.0f, new Vector2(position.X, position.Y));

				// a bit complicated this way
				ButtonArea = new Rectangle((int)position.X - (int)Size.X / 2, (int)position.Y - (int)Size.Y / 2, (int)Size.X, (int)size.Y);
				collisionType = CollisionType.Circle;
			}

            buttonState = buttonState.Released;
            currentTexture = ReleasedTexture;

            Enabled = true;
			EnableTint = false;
			tintColour = Color.White;

            pressedTime = 0;
            ReleaseTime = reltime;
        }
コード例 #5
0
ファイル: WorldBounds.cs プロジェクト: tavoe/blocker
    void Awake()
    {
        // initialization
        collisionType = CollisionType.Box;

        setCollisionType(collisionType);
    }
コード例 #6
0
 public TileData()
 {
     this.texturePath = "Textures/blueBlock";
     this.collision = 0;
     this.posX = 0;
     this.posY = 0;
 }
コード例 #7
0
 public TileData(int posX, int posY, String texturePath, CollisionType collision)
 {
     this.texturePath = texturePath;
     this.collision = collision;
     this.posX = posX;
     this.posY = posY;
 }
コード例 #8
0
        //List<Polygon> polygons
        public CollisionComponent(GameObject gameObject, List<Polygon> polygons, List<AABB> axisAlignedBoxes)
            : base(gameObject)
        {
            Name = "CollisionComponent";

            this.axisAlignedBoxes = axisAlignedBoxes;
            this.polygons = polygons;
            hasCollided = false;

            if (polygons != null && axisAlignedBoxes != null)
            {
                collisionType = CollisionType.POLYGON_AND_AABB;
                ParentObject.Properties.updateProperty<List<AABB>>("AABB", axisAlignedBoxes);
                ParentObject.Properties.updateProperty<List<Polygon>>("Polygon", polygons);
            }
            else if (polygons != null)
            {
                collisionType = CollisionType.POLYGON;
                ParentObject.Properties.updateProperty<List<Polygon>>("Polygon", polygons);
            }
            else if (axisAlignedBoxes != null)
            {
                collisionType = CollisionType.AABB;
                ParentObject.Properties.updateProperty<List<AABB>>("AABB", axisAlignedBoxes);
            }
            else
            {
                collisionType = CollisionType.NO_TYPE;
            }

            ParentObject.Properties.updateProperty<CollisionType>("CollisionType", collisionType);
            ParentObject.Properties.updateProperty<bool>("HasCollided", hasCollided);
            ParentObject.Properties.updateProperty<bool>("IsCollisionActive", true);
        }
コード例 #9
0
ファイル: Missile.cs プロジェクト: RyanAdamsGD/City-Defense
 public Missile(Game game, Model m, CollisionType type, Vector3 start, Entity target, float speed)
     : base(game,m,type,start,Vector3.Zero,speed,50)
 {
     var exhaust = new MissileExhaustParticleSystem(game, ((Game1)Game).Content);
     ParticleEmitterManager.addParticleEmitter(new ParticleEmitter(Game, exhaust, 1000, lifeTime, getExhaustPosition));
     addComponent(new PathingChase(game, this, target, speed, true));
 }
コード例 #10
0
ファイル: CollisionUnit.cs プロジェクト: sgdc/sgdc-old
 /// <summary>
 /// Instantiate a new CollisionUnit. This constructor is for circle based collisions.
 /// </summary>
 /// <param name="owner">The "owner" Entity that this CollisionUnit will be for.</param>
 /// <param name="center">The location of the circle center.</param>
 /// <param name="radius">The radius of the circle.</param>
 /// <param name="collisionMask">Collision mask for the object.</param>
 /// <param name="bUsePixelCollision">Is pixel-perfect collisions should be used.</param>
 public CollisionUnit(Entity owner, Vector2 center, int radius, Texture2D collisionMask, bool bUsePixelCollision)
 {
     InitializeCommonStuff(owner, collisionMask, bUsePixelCollision);
     mCircleCenter = center;
     mCircleRadius = radius;
     mOrigRadius = radius;
     mCollisionType = CollisionType.COLLISION_CIRCLE;
 }
コード例 #11
0
		public override void Reset()
		{
			collision = CollisionType.OnCollisionEnter;
			collideTag = "Untagged";
			sendEvent = null;
			storeCollider = null;
			storeForce = null;
		}
コード例 #12
0
ファイル: Collision.cs プロジェクト: cemusta/NSGAII_UCT
 public Collision(CollisionType type = CollisionType.CourseCollision)
 {
     Result = 0;
     TeacherId = -1;
     SlotId = -1;
     Type = type;
     CrashingCourses = new List<Course>();
 }
コード例 #13
0
        /// <summary>
        /// Indicates whether the class can traverse this CollisionType or not.
        /// </summary>
        /// <param name="toTraverse">
        /// The CollisionType to traverse.
        /// </param>
        /// <returns>
        /// True if the unit can traverse it.
        /// False if the unit cannot.
        /// </returns>
        public override bool CanTraverse(CollisionType toTraverse)
        {
            if (toTraverse == CollisionType.None)
            {
                return true;
            }

            return false;
        }
コード例 #14
0
ファイル: Trile.cs プロジェクト: tanis2000/FEZ
 public Trile(CollisionType faceType)
   : this()
 {
   this.Faces.Add(FaceOrientation.Back, faceType);
   this.Faces.Add(FaceOrientation.Front, faceType);
   this.Faces.Add(FaceOrientation.Left, faceType);
   this.Faces.Add(FaceOrientation.Right, faceType);
   this.MissingTrixels.OnDeserialization();
 }
コード例 #15
0
        void Start()
        {
            // Set collision
            // toggle ON/OFF your choice of raycast

            //collisionType = CollisionType.CLICKHITONE;		// hit just one object
            collisionType = CollisionType.CLICKHITALL;          // hit multiple objects overlapping
                                                                //collisionType = CollisionType.MOUSEPOSITION;		// continuous mouse position detection
        }
コード例 #16
0
        protected override int AddNewData()
        {
            m_collisionType = DataManager.Generate<CollisionType>();
            m_collisionType.Name = m_textBox_name.Text;

            DataManager.CollisionTypes.Add(m_collisionType);

            return m_collisionType.Id;
        }
コード例 #17
0
ファイル: Collidable.cs プロジェクト: kozupi/--
 public Collidable(Game game, Entity.Entity parent, CollisionType type, CollisionEvent e, int health, int damage, Collidable parentCollidable, BoundingBox boundingBox)
     : base(game, parent)
 {
     this.onCollision = e;
     this.type = type;
     this.health = health;
     this.damage = damage;
     children = new List<Collidable>();
     parentCollidable.addChild(this);
     this.boundingBox = boundingBox;
 }
コード例 #18
0
ファイル: Collidable.cs プロジェクト: kozupi/--
 public Collidable(Game game, Entity.Entity parent, CollisionType type, CollisionEvent e, int health, int damage,Collidable parentCollidable, float range = 50.0f)
     : base(game, parent)
 {
     this.onCollision = e;
     this.type = type;
     this.health = health;
     this.damage = damage;
     children = new List<Collidable>();
     parentCollidable.addChild(this);
     rangeSquared = range * range;
 }
コード例 #19
0
ファイル: Tile.cs プロジェクト: Terhands/LazerSharktopus
        /* set up the tile -> figure out it's position in the level, it's size relative to the screen & load the sprite+set the collision behaviour */
        public Tile(Texture2D texture, CollisionType type, int xIndex, int yIndex, int screenWidth, int screenHeight)
        {
            LoadContent(texture, type);
            position = new Rectangle();

            position.Width = screenWidth/64;
            position.Height = screenHeight/32;

            position.X = xIndex * position.Width;
            position.Y = yIndex * position.Height;
        }
コード例 #20
0
 public void OnAwakeByPool( bool used )
 {
     if( !used )
     {
         this.cachedRadius = this.radius;
     }
     ReferenceManager.Instance.refCollisionManager.AddEnemyShotCollider( this );
     this.radius = grazeRadius;
     this.collisionType = CollisionType.Graze;
     this.enabled = true;
 }
コード例 #21
0
 public void SetValue(int x, int y, CollisionType value)
 {
     if (x >= 0 && y >= 0 && x < width && y < height)
     {
         values[x, y] = value;
     }
     else
     {
         Console.WriteLine("Attempted to set collisionType outside of the grid at " + x.ToString() + "," + y.ToString() + ".");
         Console.WriteLine("Ignoring.");
     }
 }
コード例 #22
0
        /// <summary>
        /// Indicates whether the unit can traverse this CollisionType or not.
        /// </summary>
        /// <param name="toTraverse">
        /// The CollisionType to traverse.
        /// </param>
        /// <returns>
        /// True if the unit can traverse it.
        /// False if the unit cannot.
        /// </returns>
        public override bool CanTraverse(CollisionType toTraverse)
        {
            if (toTraverse == CollisionType.None ||
                toTraverse == CollisionType.Mountain ||
                toTraverse == CollisionType.Water ||
                toTraverse == CollisionType.Flyable)
            {
                return true;
            }

            return false;
        }
コード例 #23
0
ファイル: Tile.cs プロジェクト: Terhands/LazerSharktopus
        /* set up the tile -> figure out it's position in the level, it's size relative to the screen & load the sprite+set the collision behaviour */
        public Tile(Game game, Texture2D texture, CollisionType type, int xIndex, int yIndex, int screenWidth, int screenHeight, int rowsPerScreen, int colsPerScreen)
            : base(game)
        {
            LoadContent(texture, type);
            position = new Rectangle();

            position.Width = screenWidth/colsPerScreen;
            position.Height = screenHeight/rowsPerScreen;

            position.X = xIndex * position.Width;
            position.Y = yIndex * position.Height;
        }
コード例 #24
0
	void OnTriggerExit2D(Collider2D col){
		if (col.tag == "no_walkable") {
			if(collisionType == CollisionType.Wall){
				collisionType = CollisionType.None;
			}
		} 
		else if (col.tag == "targetZone") {
			if(collisionType == CollisionType.Target){
				collisionType = CollisionType.None;
			}
		}	

	}
コード例 #25
0
	void OnTriggerStay2D(Collider2D col){
		if (col.tag == "no_walkable") {
			Debug.Log("Colision muro");
			collisionType = CollisionType.Wall;
		} 
		else if (col.tag == "targetZone") {
			collisionType = CollisionType.Target;
			lastObject = col.gameObject;
			Debug.Log("Colision target");
		}	



	}
コード例 #26
0
        public UserControl_CollisionType(CollisionType collisionType)
            : base("Collision Type", false)
        {
            m_collisionType = collisionType;

            if (DataIsNull())
            {
                m_textBlock_id.Text = "N/A";
                m_textBox_name.Text = string.Empty;
            }
            else
            {
                m_textBlock_id.Text = m_collisionType.Id.ToString();
                m_textBox_name.Text = m_collisionType.Name;
            }
        }
コード例 #27
0
ファイル: CollisionUnit.cs プロジェクト: sgdc/sgdc-old
 /// <summary>
 /// Instantiate a new CollisionUnit. This constructor is for line and box based collisions.
 /// </summary>
 /// <param name="owner">The "owner" Entity that this COllisionUnit will be for.</param>
 /// <param name="point1">A point on the line or a corner of the box. For line, this is the start. For box, this is the upper-left corner.</param>
 /// <param name="point2">A point on the line or a corner of the box. For line, this is the end. For box, this is the lower-right corner.</param>
 /// <param name="collisionType">
 /// The collision type to use. The only accepted value is <see cref="CollisionType.COLLISION_LINE"/>, which makes this a line based collision unit. All other values default to box based collision.
 /// </param>
 /// <param name="collisionMask">Collision mask for the object.</param>
 /// <param name="bUsePixelCollision">Is pixel-perfect collisions should be used.</param>
 public CollisionUnit(Entity owner, Vector2 point1, Vector2 point2, CollisionType collisionType, Texture2D collisionMask, bool bUsePixelCollision)
 {
     InitializeCommonStuff(owner, collisionMask, bUsePixelCollision);
     mPoint1 = point1;
     mPoint2 = point2;
     if (collisionType == CollisionType.COLLISION_LINE)
     {
         mCollisionType = CollisionType.COLLISION_LINE;
     }
     else
     {
         mCollisionType = CollisionType.COLLISION_BOX;
         mOrigWidth = (int)(mPoint2.X - mPoint1.X);
         mOrigHeight = (int)(mPoint2.Y - mPoint2.Y);
     }
 }
コード例 #28
0
        public MapManager(GameManager gameManager, int totalRegionWidth, int totalRegionHeight)
        {
            myGameManager = gameManager;
            myTotalRegionWidth = totalRegionWidth;
            myTotalRegionHeight = totalRegionHeight;
            GameMaps = new JsDictionary<string, GameMap>();
            GameMapLayouts = new List<GameMapLayout>();

            CollisionMap = new CollisionType[myTotalRegionWidth][];
            for (int x = 0; x < myTotalRegionWidth; x++) {
                CollisionMap[x] = new CollisionType[myTotalRegionHeight];
                for (int y = 0; y < myTotalRegionHeight; y++) {
                    CollisionMap[x][y] = 0;
                }
            }
        }
コード例 #29
0
ファイル: Bullet.cs プロジェクト: RyanAdamsGD/City-Defense
        public Bullet(Game game, Model m,CollisionType type, Vector3 start, Vector3 target, float speed, int damage = 20)
            : base(game)
        {
            addComponent(new Spatial(game, this, start));
            getComponent<Spatial>().position = start;
            getComponent<Spatial>().transform *= Matrix.CreateScale(0.1f);
            addComponent(new Drawable3D(game, this, m));
            addComponent(new Collidable(game, this, type, onHit,1,damage,getComponent<Drawable3D>().modelBoundingBox));
            Vector3 focus = target - start;
            Matrix mat = Vector3.Backward.align(focus);
            getComponent<Spatial>().transform = mat * Matrix.CreateScale(3.0f) * Matrix.CreateTranslation(start);
            getComponent<Spatial>().focus = focus + start;
            this.speed = speed;

            this.target = Vector3.Normalize(target - start) * this.speed;
            time = 0.0f;
        }
コード例 #30
0
ファイル: Tile.cs プロジェクト: Terhands/LazerSharktopus
        /* load the basic Tile properties (the texture/collision properties) */
        public void LoadContent(Texture2D texture, CollisionType cType)
        {
            tileTexture = texture;
            collisionBehaviour = cType;

            switch (collisionBehaviour)
            {
                case CollisionType.impassable:
                    color = Color.Silver;
                    break;
                case CollisionType.passable:
                    color = Color.Transparent;
                    break;
                case CollisionType.platform:
                    color = Color.SteelBlue;
                    break;
            }
        }
コード例 #31
0
 public BoulderItem(Rectangle position, AbstractAnimatedSprite sprite, CollisionType collisionType, string message)
     : base(position, sprite, collisionType, message)
 {
 }
コード例 #32
0
 public SpiderEnemy(Rectangle position, int power, int speed, int jumpFrequency, SpriteOrientation spriteOrientation, CollisionType collisionType, string message)
 {
     this.Position              = new Vector2(position.X, position.Y);
     this.Size                  = new Vector2(position.Width, position.Height);
     this.Power                 = power;
     this.Velocity              = new Vector2(0, (spriteOrientation == SpriteOrientation.Up ? -1 : 1) * speed);
     this.isJumping             = false;
     this.jumpFrequency         = jumpFrequency;
     this.jumpCurrent           = 0;
     this.IsAlive               = true;
     this.ShouldNotifyReceivers = false;
     this.spriteOrientation     = spriteOrientation;
     this.sprite                = SpriteFactory.GetSpiderSprite(this.spriteOrientation);
     this.CollisionType         = collisionType;
     this.MessageToReceivers    = message;
 }
コード例 #33
0
 public static bool CheckTile(Map m, Point3D p, CollisionType flag)
 {
     return(CheckTile(m, p.X, p.Y, flag));
 }
コード例 #34
0
    void ResolveCollisions(RaycastHit2D hit, CollisionType collisionType, ref Vector2 velocity, float moveDir, ref float rayLength)
    {
        collisions.collided = true;

        if (collisionType == CollisionType.HORIZONTAL && hit.distance == 0)
        {
            if (hit.transform.tag != "Hazard")
            {
                return;
            }
        }

        if (hit.transform.tag != "Gravity Switch")
        {
            if (!canFlipGravity)
            {
                canFlipGravity = true;
            }
        }

        switch (hit.transform.tag)
        {
        case "Hazard":
            if (!collisions.hitHazard)     //fix after making collisions end after 1 ray... doesn't really make sense to continue w/o slopes
            {
                if (!invincible)
                {
                    OnHazard();
                    collisions.hitHazard = true;
                }
            }
            break;

        case "Powerup":
            Powerup pw = hit.collider.GetComponent <Powerup>();
            powerups.AddLast(pw.GetPowerupType());
            if (powerups.Count > powerupSize && !greedy)
            {
                powerups.RemoveFirst();
            }
            UpdatePowerupUI();
            pw.Consume();
            return;

        case "Goal":
            EntityManager.instance.levelComplete = true;
            hit.collider.GetComponent <Goal>().GoalComplete();
            return;

        case "Through":
            if (collisionType == CollisionType.VERTICAL)
            {
                if (moveDir == 1 || hit.distance == 0 || userInput.y == -1)     //watch for bugs from removing fallingThroughPlat, invoke after .5 sec delay (seblague)
                {
                    return;
                }
                break;
            }
            else
            {
                return;
            }

        case "Yoku":
            if (collisionType == CollisionType.VERTICAL)
            {
                if (hit.distance == 0)
                {
                    return;
                }
            }
            break;

        case "Ice":
            if (collisionType == CollisionType.VERTICAL)
            {
                groundAcceleration = 0.75f;
            }
            break;

        case "Gravity Switch":
            if (canFlipGravity)
            {
                FlipGravity();
                canFlipGravity = false;
                return;
            }
            else
            {
                return;
            }

        case "Entity Switch":
            hit.collider.GetComponent <Switch>().Consume();
            return;

        case "Quicksand":
            inQuicksand = true;
            return;

        case "Water":
            if (!inWater)
            {
                inWater         = true;
                this.velocity.y = Mathf.Clamp(this.velocity.y, -2f, 10f);
            }
            collisions.collidedWater = true;
            return;

        case "Checkpoint":
            spawnPoint = hit.transform.position;
            hit.collider.GetComponent <Goal>().GoalComplete();
            return;

        default:
            break;
        }

        if (collisionType == CollisionType.VERTICAL)
        {
            velocity.y = (hit.distance - SKIN_WIDTH) * moveDir;
            rayLength  = hit.distance;

            if (!gravityFlipped)
            {
                collisions.below = moveDir == -1;
                collisions.above = moveDir == 1;
            }
            else
            {
                collisions.below = moveDir == 1;
                collisions.above = moveDir == -1;
            }
        }
        else
        {
            velocity.x = Mathf.Min(Mathf.Abs(velocity.x), (hit.distance - SKIN_WIDTH)) * moveDir;
            rayLength  = Mathf.Min(Mathf.Abs(velocity.x) + SKIN_WIDTH, hit.distance);

            collisions.left  = moveDir == -1;
            collisions.right = moveDir == 1;
        }
    }
コード例 #35
0
 public Collision(int R)
 {
     radius       = R;
     colisionType = CollisionType.Circle;
 }
コード例 #36
0
 public Task <string> ToFile(FileInfo src, string destFilePath, bool copy, CollisionType collision = CollisionType.Error)
 {
     return(Enqueue(new CopyMoveFilePair(src, destFilePath, copy, collision)));
 }
コード例 #37
0
 public Spike(int posX, int posY, char symbol = '▲', CollisionType collisionType = CollisionType.spike) : base(posX, posY, symbol, collisionType)
 {
 }
コード例 #38
0
ファイル: MetaTileMap.cs プロジェクト: jedi5218/unitystation
        private bool IsPassableAtOrthogonal(Vector3Int origin, Vector3Int to, bool isServer,
                                            CollisionType collisionType    = CollisionType.Player, bool inclPlayers = true, GameObject context = null,
                                            List <LayerType> excludeLayers = null, List <TileType> excludeTiles     = null, bool ignoreObjects = false, bool isReach = false)
        {
            if (ignoreObjects == false &&
                ObjectLayer.IsPassableAtOnThisLayer(origin, to, isServer, collisionType, inclPlayers, context, excludeTiles, isReach: isReach) == false)
            {
                return(false);
            }

            TileLocation TileLcation = null;

            for (var i = 0; i < SolidLayersValues.Length; i++)
            {
                // Skip floor & base collisions if this is not a shuttle
                if (collisionType != CollisionType.Shuttle &&
                    (SolidLayersValues[i].LayerType == LayerType.Floors ||
                     SolidLayersValues[i].LayerType == LayerType.Base))
                {
                    continue;
                }

                // Skip if the current tested layer is being excluded.
                if (excludeLayers != null && excludeLayers.Contains(SolidLayersValues[i].LayerType))
                {
                    continue;
                }

                lock (PresentTiles)
                {
                    PresentTiles[SolidLayersValues[i]].TryGetValue(to, out TileLcation);
                }

                if (TileLcation?.Tile == null)
                {
                    continue;
                }
                var tile = TileLcation.Tile as BasicTile;

                // Return passable if the tile type is being excluded from checks.
                if (excludeTiles != null && excludeTiles.Contains(tile.TileType))
                {
                    continue;
                }

                if (tile.IsPassable(collisionType, origin, this) == false)
                {
                    return(false);
                }

                // if ((TileLcation.Tile as BasicTile).IsAtmosPassable() == false)
                // {
                // return false;
                // }

                // if (!SolidLayersValues[i].IsPassableAt(origin, to, isServer, collisionType: collisionType,
                // inclPlayers: inclPlayers, context: context, excludeTiles))
                // {
                // return false;
                // }
            }

            return(true);
        }
コード例 #39
0
        protected override void CheckCollisionWithGround()
        {
            int       index = Mathematics.PositionToIndex(Position.X);
            LevelTile tile;

            if (index > -1 && index < refToLevel.LevelTiles.Count)
            {
                tile = refToLevel.LevelTiles[index];
                if (tile is ShipTile)
                {
                    //boundRectangle.Intersects(
                }
                //CollisionType c = CollisionType.None;
                CollisionType c = tile.InCollision(this.boundRectangle);
                if (c == CollisionType.None)
                {
                    return;
                }

                //jesli nie da sie zniszczyc dany obiekt rakieta.
                if (c == CollisionType.Hitbound || c == CollisionType.CollisionRectagle)
                {
                    if (tile is BarrelTile)
                    {
                        BarrelTile destroyTile = tile as BarrelTile;
                        if (!destroyTile.IsDestroyed)
                        {
                            destroyTile.Destroy();
                            refToLevel.Controller.OnTileDestroyed(destroyTile, this);
                            refToLevel.Statistics.HitByRocket += refToLevel.KillVulnerableSoldiers(index, 2, true);
                        }
                        else
                        {
                            refToLevel.Controller.OnTileBombed(tile, this);
                        }
                    }
                    else if (tile is EnemyInstallationTile)
                    {
                        FortressBunkerTile    fortressTile = null;
                        EnemyInstallationTile enemyTile    = null;
                        LevelTile             destroyTile  = tile;
                        //Obsluga fortress bunker
                        if ((fortressTile = destroyTile as FortressBunkerTile) != null && !fortressTile.IsDestroyed)
                        {
                            //Trafienie zniszczonego fortress bunker
                            if (fortressTile.IsDestroyed)
                            {
                                refToLevel.Controller.OnTileBombed(destroyTile, this);
                            }
                            else
                            {
                                fortressTile.Hit();
                                //Ostatnie trafienie!
                                if (fortressTile.ShouldBeDestroyed)
                                {
                                    refToLevel.Controller.OnTileDestroyed(destroyTile, this);
                                    refToLevel.Statistics.HitByRocket++;
                                    fortressTile.Destroy();
                                }
                                //Trafienie rakiety uszkadzaj¹ce fortress bunker
                                else
                                {
                                    refToLevel.Controller.OnFortressHit(fortressTile, this);
                                    refToLevel.Statistics.HitByRocket++;
                                }
                            }
                        }
                        else if ((enemyTile = destroyTile as EnemyInstallationTile) != null && !enemyTile.IsDestroyed)
                        {
                            refToLevel.Controller.OnTileDestroyed(destroyTile, this);
                            refToLevel.Statistics.HitByRocket++;
                            enemyTile.Destroy();
                        }
                        else
                        {
                            refToLevel.Controller.OnTileBombed(tile, this);
                        }
                    }
                    else
                    {
                        refToLevel.Controller.OnTileBombed(tile, this);
                    }
                }
                else if (c == CollisionType.Altitude)
                {
                    refToLevel.Controller.OnTileBombed(tile, this);
                }


                //zabija zolnierzy, ktorzy sa w zasiegu.
                refToLevel.Statistics.HitByRocket += refToLevel.KillVulnerableSoldiers(index, 1, true);

                //niszcze rakiete
                Destroy();
            }
        }
コード例 #40
0
    ///Cross-matrix edition of <see cref="Matrix.IsPassableAt(UnityEngine.Vector3Int,UnityEngine.Vector3Int,bool,GameObject)"/>
    ///<inheritdoc cref="Matrix.IsPassableAt(UnityEngine.Vector3Int,UnityEngine.Vector3Int,bool,GameObject)"/>
    public static bool IsPassableAt(Vector3Int worldOrigin, Vector3Int worldTarget, bool isServer, CollisionType collisionType = CollisionType.Player, bool includingPlayers = true, GameObject context = null, int[] excludeList = null)
    {
        // Gets the list of Matrixes to actually check
        MatrixInfo[] includeList = excludeList != null?ExcludeFromAllMatrixes(GetList(excludeList)).ToArray() : Instance.ActiveMatrices.ToArray();

        return(AllMatchInternal(mat =>
                                mat.Matrix.IsPassableAt(WorldToLocalInt(worldOrigin, mat), WorldToLocalInt(worldTarget, mat), isServer,
                                                        collisionType: collisionType, includingPlayers: includingPlayers, context: context), includeList));
    }
コード例 #41
0
 public CollisionTypeFilterGroup(CollisionType t, uint g, uint m)
 {
     type  = t;
     group = g;
     mask  = m;
 }
コード例 #42
0
 public void DisableDetector()
 {
     mCollider.enabled = false;
     collisionType     = CollisionType.None;
     //lastObject = null;
 }
コード例 #43
0
        private bool updateOnce(ref bool collisionHappened)
        {
            bool verticalChange    = false;
            bool outsideVertical   = false;
            bool horizontalChange  = false;
            bool outsideHorizontal = false;

            //check only for changes
            switch (horizontal)
            {
            case (edgeOrder.ppbb):
            {
                if (_proj.rightCollision > _box.leftCollision)
                {
                    horizontal        = edgeOrder.pbpb;
                    horizontalResult |= CollisionType.leftTop | CollisionType.intruding;
                    horizontalChange  = true;
                }
                outsideHorizontal = true;
                break;
            }

            case (edgeOrder.pbpb):
            {
                if (_proj.rightCollision < _box.leftCollision)
                {
                    horizontal        = edgeOrder.ppbb;
                    horizontalResult |= CollisionType.leftTop | CollisionType.excluding;
                    horizontalChange  = true;
                }
                if (_proj.leftCollision > _box.leftCollision)
                {
                    horizontal        = edgeOrder.bppb;
                    horizontalResult |= CollisionType.leftTop | CollisionType.including;
                    horizontalChange  = true;
                }
                if (_proj.rightCollision > _box.rightCollision)
                {
                    horizontal        = edgeOrder.pbbp;
                    horizontalResult |= CollisionType.rightBottom | CollisionType.extruding;
                    horizontalChange  = true;
                }
                break;
            }

            case (edgeOrder.bppb):
            {
                if (_proj.leftCollision < _box.leftCollision)
                {
                    horizontal        = edgeOrder.pbpb;
                    horizontalResult |= CollisionType.leftTop | CollisionType.extruding;
                    horizontalChange  = true;
                }
                if (_proj.rightCollision > _box.rightCollision)
                {
                    horizontal        = edgeOrder.bpbp;
                    horizontalResult |= CollisionType.rightBottom | CollisionType.extruding;
                    horizontalChange  = true;
                }
                break;
            }

            case (edgeOrder.pbbp):
            {
                if (_proj.rightCollision < _box.rightCollision)
                {
                    horizontal        = edgeOrder.pbpb;
                    horizontalResult |= CollisionType.rightBottom | CollisionType.including;
                    horizontalChange  = true;
                }
                if (_proj.leftCollision > _box.leftCollision)
                {
                    horizontal        = edgeOrder.bpbp;
                    horizontalResult |= CollisionType.leftTop | CollisionType.including;
                    horizontalChange  = true;
                }
                break;
            }

            case (edgeOrder.bpbp):
            {
                if (_proj.rightCollision < _box.rightCollision)
                {
                    horizontal        = edgeOrder.bppb;
                    horizontalResult |= CollisionType.rightBottom | CollisionType.including;
                    horizontalChange  = true;
                }
                if (_proj.leftCollision < _box.leftCollision)
                {
                    horizontal        = edgeOrder.pbbp;
                    horizontalResult |= CollisionType.leftTop | CollisionType.extruding;
                    horizontalChange  = true;
                }
                if (_proj.leftCollision > _box.rightCollision)
                {
                    horizontal        = edgeOrder.bbpp;
                    horizontalResult |= CollisionType.rightBottom | CollisionType.excluding;
                    horizontalChange  = true;
                }
                break;
            }

            case (edgeOrder.bbpp):
            {
                if (_proj.leftCollision < _box.rightCollision)
                {
                    horizontal        = edgeOrder.bpbp;
                    horizontalResult |= CollisionType.rightBottom | CollisionType.intruding;
                    horizontalChange  = true;
                }
                outsideHorizontal = true;
                break;
            }
            } //end select


            switch (vertical)
            {
            case (edgeOrder.ppbb):
            {
                if (_proj.bottomCollision > _box.topCollision)
                {
                    vertical        = edgeOrder.pbpb;
                    verticalResult |= CollisionType.leftTop | CollisionType.intruding;
                    verticalChange  = true;
                }
                outsideVertical = true;
                break;
            }

            case (edgeOrder.pbpb):
            {
                if (_proj.bottomCollision < _box.topCollision)
                {
                    vertical        = edgeOrder.ppbb;
                    verticalResult |= CollisionType.leftTop | CollisionType.excluding;
                    verticalChange  = true;
                }
                if (_proj.topCollision > _box.topCollision)
                {
                    vertical        = edgeOrder.bppb;
                    verticalResult |= CollisionType.leftTop | CollisionType.including;
                    verticalChange  = true;
                }
                if (_proj.bottomCollision > _box.bottomCollision)
                {
                    vertical        = edgeOrder.pbbp;
                    verticalResult |= CollisionType.rightBottom | CollisionType.extruding;
                    verticalChange  = true;
                }
                break;
            }

            case (edgeOrder.bppb):
            {
                if (_proj.topCollision < _box.topCollision)
                {
                    vertical        = edgeOrder.pbpb;
                    verticalResult |= CollisionType.leftTop | CollisionType.extruding;
                    verticalChange  = true;
                }
                if (_proj.bottomCollision > _box.bottomCollision)
                {
                    vertical        = edgeOrder.bpbp;
                    verticalResult |= CollisionType.rightBottom | CollisionType.extruding;
                    verticalChange  = true;
                }
                break;
            }

            case (edgeOrder.pbbp):
            {
                if (_proj.bottomCollision < _box.bottomCollision)
                {
                    vertical        = edgeOrder.pbpb;
                    verticalResult |= CollisionType.rightBottom | CollisionType.including;
                    verticalChange  = true;
                }
                if (_proj.topCollision > _box.topCollision)
                {
                    vertical        = edgeOrder.bpbp;
                    verticalResult |= CollisionType.leftTop | CollisionType.including;
                    verticalChange  = true;
                }
                break;
            }

            case (edgeOrder.bpbp):
            {
                if (_proj.bottomCollision < _box.bottomCollision)
                {
                    vertical        = edgeOrder.bppb;
                    verticalResult |= CollisionType.rightBottom | CollisionType.including;
                    verticalChange  = true;
                }
                if (_proj.topCollision < _box.topCollision)
                {
                    vertical        = edgeOrder.pbbp;
                    verticalResult |= CollisionType.leftTop | CollisionType.extruding;
                    verticalChange  = true;
                }
                if (_proj.topCollision > _box.bottomCollision)
                {
                    vertical        = edgeOrder.bbpp;
                    verticalResult |= CollisionType.rightBottom | CollisionType.excluding;
                    verticalChange  = true;
                }
                break;
            }

            case (edgeOrder.bbpp):
            {
                if (_proj.topCollision < _box.bottomCollision)
                {
                    vertical        = edgeOrder.bpbp;
                    verticalResult |= CollisionType.rightBottom | CollisionType.intruding;
                    verticalChange  = true;
                }
                outsideVertical = true;
                break;
            }
            } //end select

            collisionHappened |=
                (
                    (verticalChange & !outsideHorizontal) || (horizontalChange && !outsideVertical)
                );
            return(verticalChange || horizontalChange);
        }
コード例 #44
0
 public Entity(Texture2D sprite, CollisionType collision = CollisionType.None)
 {
     Sprite    = sprite;
     Collision = collision;
 }
コード例 #45
0
        public Task <string> ToFolder(FileInfo src, string destFolderPath, bool copy, CollisionType collision = CollisionType.Error)
        {
            string destFilePath = Path.Combine(destFolderPath, src.Name);

            return(ToFile(src, destFilePath, copy, collision));
        }
コード例 #46
0
 public Entity(Texture2D sprite, Vector2 pos, Vector2 vel, float rotspeed, float mass, CollisionType collision = CollisionType.None)
 {
     Sprite    = sprite;
     Position  = pos;
     Velocity  = vel;
     RotSpeed  = rotspeed;
     Mass      = mass;
     Collision = collision;
 }
コード例 #47
0
 public Spike(char symbol = '▲', CollisionType collisionType = CollisionType.spike) : base(symbol, collisionType)
 {
 }
コード例 #48
0
 public Tile(Rectangle loc, Rectangle imgSource, CollisionType collisionType) : this(loc.X, loc.Y, imgSource, collisionType)
 {
 }
コード例 #49
0
 public Collision(int W, int H)
 {
     Width        = W;
     Height       = H;
     colisionType = CollisionType.Square;
 }
コード例 #50
0
 public Tile(int x_coord, int y_coord, Rectangle imgSource, CollisionType collisionType)
 {
     loc                = new Rectangle(x_coord * TILE_SIZE, y_coord * TILE_SIZE, TILE_SIZE, TILE_SIZE);
     this.imgSource     = imgSource;
     this.collisionType = collisionType;
 }
コード例 #51
0
 public MapTile(Map Map, CollisionType Flag, EventTile Event)
 {
     mMap   = Map;
     mFlag  = Flag;
     mEvent = Event;
 }
コード例 #52
0
        public void GetCollisionTypeTest()
        {
            CollisionType collisionType = CollisionManager.GetCollisionType('#');

            Assert.That(CollisionType.Impassable, Is.EqualTo(collisionType));
        }
コード例 #53
0
 public MapTile(Map Map, CollisionType Flag)
 {
     mMap  = Map;
     mFlag = Flag;
 }
コード例 #54
0
 public Tile(int id, CollisionType collision)
 {
     Id        = id;
     Collision = collision;
 }
コード例 #55
0
 public static bool CheckTile(Map m, int X, int Y, CollisionType flag)
 {
     return((m[X, Y].Flag & flag) == flag);
 }
コード例 #56
0
    private void OnCollision(BallBase ball, RaycastHit2D rayHit, CollisionSide colSide, CollisionType colType, float totalDistance, float endSpeed, int safe, ICollider collidingObject, out float distanceAfterHit)
    {
        if (totalDistance <= 0)
        {
            rayHits = new RaycastHit2D[0];
            Debug.LogWarning("TOTAL DISTNANCE <= 0!");
            distanceAfterHit = 0;
            return;
        }

        Vector2 lastFramePos  = ball.LastFrameCenterPoint;
        Vector2 velocity      = LastFrameVelocity;
        Vector2 actualPos     = currentCenterPoint;
        Vector2 centroidPoint = rayHit.centroid;

        float colRadius           = Collider.radius / 2;
        float distanceToCollision = rayHit.distance;

        distanceAfterHit = totalDistance - distanceToCollision;
        // Debug.LogFormat("[{3}] distanceToCollision: {0}, total distance: {1} distanceAfterHit: {2}", distanceToCollision, totalDistance, distanceAfterHit, safe);

        Debug.DrawLine(centroidPoint, rayHit.point, Color.blue, 2);
        Debug.DrawLine(actualPos, lastFramePos, safe == 0 ? Color.black : Color.yellow, 2);
        Debug.DrawLine(actualPos, centroidPoint, Color.green, 2);

        Vector2 newPos;
        bool    overlapping = distanceToCollision == 0;

        Debug.LogFormat("Collision. side: {0} type: {1} overlap: {2}, last framePos: {3} actualPos: {4}", colSide, colType, overlapping, lastFramePos, actualPos);
        if (overlapping)
        {
            Debug.LogWarningFormat("OVERLAPPING! To collision: {0} total distance: {1}", distanceToCollision, totalDistance);
            overlapping      = true;
            newPos           = GetNewPositionWhenOverlaping(colType, colSide, collidingObject, rayHit, actualPos, colRadius);
            distanceAfterHit = totalDistance - (newPos - lastFramePos).magnitude;
            Debug.Log("new distance after hit: " + distanceAfterHit);
            if (distanceAfterHit <= -100)
            {
                Debug.Log("FAIL");
            }
            // newPos = GetNewPositionBasedOnCollisionType(colType, colSide, newPos, velocity, distanceAfterHit);
            // Debug.LogFormat("Pos changed: {0} to {1}", lastFramePos, newPos);
        }
        else
        {
            newPos = GetNewPositionBasedOnCollisionType(colType, colSide, centroidPoint, velocity, collidingObject, distanceAfterHit);

            Vector2 endVel = SetVelocityBasedOnCollisionType(colType, colSide, collidingObject, endSpeed, LastFrameVelocity);
            LastFrameVelocity = endVel;
            Debug.Log("change velocity to " + (endVel.y < 0 ? "DOWN" : "UP"));
        }

        ball.transform.position = newPos;
        Debug.DrawLine(centroidPoint, newPos, safe == 0 ? Color.red : Color.grey, 2);
        currentCenterPoint = newPos;

        if (overlapping)
        {
            rayHit.centroid = newPos;
            rayHit.distance = distToMoveOnOverlap;
            //rayHits = new RaycastHit2D[1] { rayHit };
            //rayHits = Physics2D.CircleCastAll(newPos, colRadius, newPos - actualPos, distanceAfterHit, ColliderLayerMask);
            OnCollision(ball, rayHit, colSide, colType, distanceAfterHit, endSpeed, safe, collidingObject, out distanceAfterHit);
            LastFrameCenterPoint = newPos;
        }
        else
        {
            rayHits = Physics2D.CircleCastAll(centroidPoint, colRadius, newPos - centroidPoint, distanceAfterHit, ColliderLayerMask);
            LastFrameCenterPoint = rayHit.centroid;
            rayHits = rayHits.Remove(rayHit);
        }


        // Debug.LogFormat("col Y: {0}, end Y: {1}", centroidPoint.y, newPos.y);
        //  Debug.LogFormat("start vel: {0} end vel: {1}", velocity.normalized, endVel.normalized);
    }
コード例 #57
0
 public CollisionPair(Waypoint waypoint, CollisionType type)
 {
     this.waypoint = waypoint;
     this.type     = type;
 }
コード例 #58
0
ファイル: Layer.cs プロジェクト: Lankercool/unitystation
 public virtual bool IsPassableAt(Vector3Int from, Vector3Int to, bool isServer,
                                  CollisionType collisionType = CollisionType.Player, bool inclPlayers = true, GameObject context = null)
 {
     return(!tilemap.HasTile(to) || tilemap.GetTile <BasicTile>(to).IsPassable(collisionType));
 }
コード例 #59
0
        public void Initialize(LSBody b1, LSBody b2)
        {
            IsValid = true;
            if (!IsValid)
            {
                return;
            }

            if (b1.ID < b2.ID)
            {
                Body1 = b1;
                Body2 = b2;
            }
            else
            {
                Body1 = b2;
                Body2 = b1;
            }

            _ranIndex = -1;

            _isColliding = false;

            DistX        = 0;
            DistY        = 0;
            PenetrationX = 0;
            PenetrationY = 0;

            CacheSqrDistance  = b1.Radius + b2.Radius;
            CacheSqrDistance *= CacheSqrDistance;

            LeCollisionType = CollisionType.None;
            if (Body1.Shape == ColliderType.None || Body2.Shape == ColliderType.None)
            {
            }
            else if (Body1.Shape == ColliderType.Circle)
            {
                if (Body2.Shape == ColliderType.Circle)
                {
                    LeCollisionType = CollisionType.Circle_Circle;
                }
                else if (Body2.Shape == ColliderType.AABox)
                {
                    LeCollisionType = CollisionType.Circle_AABox;
                }
                else if (Body2.Shape == ColliderType.Polygon)
                {
                    LeCollisionType = CollisionType.Circle_Polygon;
                }
            }
            else if (Body1.Shape == ColliderType.AABox)
            {
                if (Body2.Shape == ColliderType.Circle)
                {
                    LeCollisionType = CollisionType.Circle_AABox;
                }
                else if (Body2.Shape == ColliderType.AABox)
                {
                    LeCollisionType = CollisionType.AABox_AABox;
                }
                else if (Body2.Shape == ColliderType.Polygon)
                {
                    LeCollisionType = CollisionType.AABox_Polygon;
                }
            }
            else if (Body1.Shape == ColliderType.Polygon)
            {
                if (Body2.Shape == ColliderType.Circle)
                {
                    LeCollisionType = CollisionType.Circle_Polygon;
                }
                else if (Body2.Shape == ColliderType.AABox)
                {
                    LeCollisionType = CollisionType.AABox_Polygon;
                }
                else if (Body2.Shape == ColliderType.Polygon)
                {
                    LeCollisionType = CollisionType.Polygon_Polygon;
                }
            }

            DoPhysics = ((Body1.IsTrigger || Body2.IsTrigger) == false);
            if (DoPhysics)
            {
            }
            Active = true;
            _Version++;
        }
コード例 #60
0
 /// Can one pass from `origin` to adjacent `position`?
 /// <param name="origin">Position object is at now</param>
 /// <param name="position">Adjacent position object wants to move to</param>
 /// <param name="includingPlayers">Set this to false to ignore players from check</param>
 /// <param name="context">Is excluded from passable check</param>
 /// <returns></returns>
 public bool IsPassableAt(Vector3Int origin, Vector3Int position, bool isServer, CollisionType collisionType = CollisionType.Player, bool includingPlayers = true, GameObject context = null, List <LayerType> excludeLayers = null, List <TileType> excludeTiles = null)
 {
     return(MetaTileMap.IsPassableAt(origin, position, isServer, collisionType: collisionType, inclPlayers: includingPlayers, context: context, excludeLayers: excludeLayers, excludeTiles: excludeTiles));
 }