コード例 #1
0
    //converte x e y nelle coordinate della cella corrispondente della griglia, rende quella cella del tipo di collisione passato
    public static void setCollisionMap(float x, float y, CollisionEntity ce)
    {
        var MapConvertionX = ((-x) + 400) / 100;
        var MapConvertionY = (y + 500) / 100;

        collisionMap[(int)Math.Round(MapConvertionY, 0), (int)Math.Round(MapConvertionX, 0)] = ce;
    }
コード例 #2
0
        // Try and assign an entity to a subdiv, otherwise assign it to this box
        public bool Assign(CollisionEntity entity)
        {
            bool result = false;

            // If it fits here, check if it can also fit in one of our subdivs, otherwise just leave it here
            if (Contains(entity))
            {
                // Check subdivs first (if any)
                if (divisions > 0)
                {
                    foreach (OctreeBox subdiv in subdivs)
                    {
                        if (subdiv.Assign(entity))
                        {
                            // Found one the entity fits in, so we can let that subdiv handle the entity
                            result = true;
                            break;
                        }
                    }
                }

                // Could not assign to any subdivs, so leave it here
                if (result == false)
                {
                    entities.Add(entity);
                    result = true;
                }

                // Increment child entity count
                childEntities++;
            }

            return(result);
        }
コード例 #3
0
ファイル: GreenPlanet.cs プロジェクト: KKMMMTTT/AstroSoar
 public override void OnCollision(CollisionEntity entity)
 {
     if (entity is Player)
     {
         ServiceProvider.SceneService.LoadScene <GreenScreen>();
     }
 }
コード例 #4
0
    public static void TM_Barrier(AIEntity pEntity)
    {
        // 在与玩家之间生成一堵半高掩体
        if (pEntity.GetComponent <trapAI> ().barrierHave == false)
        {
            return;
        }
        // 首先把头部转向玩家,以免在生成掩体时角度不对
        Vector3 dir = pEntity.PlayerPos - pEntity.AIPos;

        pEntity.GetComponent <AIMove> ().mMoveFunc  = MoveFunc.JUSTROTATE;
        pEntity.GetComponent <AIMove> ().mDirection = dir.normalized;
        GameObject tbarrier = GameObject.Instantiate(pEntity.GetComponent <trapAI> ().barrierObj,
                                                     pEntity.AIPos + dir.normalized * 1.0f,
                                                     pEntity.GetComponent <BaseAIComponent> ().mAIRT.transform.rotation);
        CollisionEntity tEntity = new CollisionEntity();

        tEntity.mGameObject = tbarrier;
        ECSWorld.MainWorld.registerEntityAfterInit(tEntity);
        tEntity.Init();
        //	tEntity.GetComponent<InfluenceMapTrigger> ().Init ();
        tbarrier.transform.right = dir.normalized;
        pEntity.GetComponent <trapAI> ().coverPosA   = tbarrier.transform.position + dir.normalized * -1.5f;
        pEntity.GetComponent <trapAI> ().coverPosB   = tbarrier.transform.position + dir.normalized * 1.5f;
        pEntity.GetComponent <trapAI> ().barrierHave = false;
    }
コード例 #5
0
        private void test(CollisionEntity entity)
        {
            map.Collision.ResetDebugOutput();
            var res = entity.Update(pt, deg, true);

            label1.Text = "Front: " + res.Front;
        }
コード例 #6
0
 public void PlayerCollisionWithPickup(CollisionEntity pickup)
 {
     if (OnPlayerCollisionWithPickUp != null)
     {
         OnPlayerCollisionWithPickUp(pickup);
     }
 }
コード例 #7
0
    public static CollisionEntity getHorizontalCollisionEntity()
    {
        var ent = new CollisionEntity();

        ent.collidesFromAbove = false;
        ent.collidesFromBelow = false;
        ent.collidesFromLeft  = true;
        ent.collidesFromRight = true;
        return(ent);
    }
コード例 #8
0
 public static void collisionMapBaseSetup()
 {
     for (int i = 0; i < 11; ++i)
     {
         for (int j = 0; j < 9; ++j)
         {
             collisionMap[i, j] = CollisionEntity.getNoCollisionEntity();
         }
     }
     //Debug.Log(collisionMap[1, 4].collidesFromAbove);
 }
コード例 #9
0
ファイル: EntityBehaviour.cs プロジェクト: 2kah/arcames
    private void UpdatePushDirection()
    {
        //work out if the other entity is pushed by us
        CollisionEffect otherEffect = rules.CollisionEffects[util.CollisionEffectsIndex(this.pushList[0].entityType, this.entityType)];

        if (this.pushList.Count == 1)
        {
            CollisionEntity pusher = this.pushList[0];
            this.moving           = pusher.moving;
            this.currentMoveSpeed = pusher.currentMoveSpeed;
        }
    }
コード例 #10
0
ファイル: CarImpl.cs プロジェクト: ddg-igh/crazy-taxi
 public CarImpl(Size dim, Size gameFieldSize, CollisionEntity entity, Size size)
 {
     this.dim           = dim;
     this.Angle         = 0;
     this.Size          = size;
     this.Car           = CT_Helper.resizeImage(Properties.Resources.Taxi_GTA2, this.Size);
     this.destroyedCar  = CT_Helper.resizeImage(Properties.Resources.GTA2_CAR_71, this.Size);
     this.entity        = entity;
     this.carCon        = new CarController();
     this.Location      = new Point(dim.Width / 2 - this.Car.Width / 2, dim.Height / 2 - this.Car.Height / 2);
     this.gameFieldSize = gameFieldSize;
     this.Destroyed     = false;
 }
コード例 #11
0
    public static CollisionEntity getFullCollisionEntity()
    {
        var ent = new CollisionEntity();

        ent.collidesFromAbove = true;
        ent.collidesFromBelow = true;
        ent.collidesFromLeft  = true;
        ent.collidesFromRight = true;
        ent.canBeExitedAbove  = true;
        ent.canBeExitedBelow  = true;
        ent.canBeExitedLeft   = true;
        ent.canBeExitedRight  = true;
        return(ent);
    }
コード例 #12
0
ファイル: Game.cs プロジェクト: ddg-igh/crazy-taxi
        private void loadMap()
        {
            DateTime start;

            gameSize = new Size(size.Width * 10, size.Height * 10);
            //Bilderordner angebe
            MapParser.ImagePath = string.Format(@"{0}{1}MapImages", Directory.GetCurrentDirectory(), Path.DirectorySeparatorChar);
            start = DateTime.Now;

            Random rnd    = new Random();
            int    random = rnd.Next(0, 3);

            switch (random)
            {
            case 0:
                map = MapParser.Load(100, 100, MapParser.SpecialMapElement.RiverCrossing);
                break;

            case 1:
                map = MapParser.Load(100, 100, MapParser.SpecialMapElement.None);
                break;

            case 2:
                map = MapParser.Load(100, 100, MapParser.SpecialMapElement.CentralPark);
                break;
            }


            Console.WriteLine("MapParser.Load:" + (System.DateTime.Now - start).ToString());
            //Karte vergrößert sich automatisch mit GUI
            //Karte im GUI anzeigen
            start = DateTime.Now;
            map.Initialize(gameSize);
            Console.WriteLine("MapParser.init:" + (System.DateTime.Now - start).ToString());
            //Karte an Größe des GUIs anpassen
            start   = DateTime.Now;
            miniMap = map.DrawImage(size);
            Console.WriteLine("MapParser.draw:" + (System.DateTime.Now - start).ToString());

            int  entityHeight = size.Height / 39;
            int  entityWidth  = size.Width / 120;
            Size entitySize   = new Size(entityWidth, entityHeight);
            Size carSize      = new Size(entityHeight, entityWidth);

            entity       = map.Collision.AddEntity(entitySize);
            car          = new CarImpl(size, gameSize, entity, carSize);
            car.Location = map.GetRandomTilePosition(true, gameSize);

            loaded = true;
        }
コード例 #13
0
        public bool Contains(CollisionEntity entity)
        {
            bool result = false;

            if (entity is CollisionBox)
            {
                result = (bounds.Contains((entity as CollisionBox).boundingBox) == ContainmentType.Contains);
            }
            else if (entity is CollisionSphere)
            {
                result = bounds.Intersects((entity as CollisionSphere).boundingSphere);
            }

            return(result);
        }
コード例 #14
0
ファイル: EntityBehaviour.cs プロジェクト: 2kah/arcames
    private void ResolveCollision(CollisionEffect effect, CollisionEntity other)
    {
        switch (effect)
        {
        case CollisionEffect.None:
            return;

        case CollisionEffect.Teleport:
            Teleport();
            return;

        case CollisionEffect.Death:
            Destroy(gameObject);
            return;

        case CollisionEffect.Push:
            Push(other);
            return;
        }
    }
コード例 #15
0
        // Test a specific entity for collisions with others in this box or in its children
        private void TestCollisions(CollisionEntity entity)
        {
            if (childEntities > 0)
            {
                foreach (CollisionEntity childEntity in entities)
                {
                    if (entity.Test(childEntity))
                    {
                        entity.collisions.Add(childEntity);
                        childEntity.collisions.Add(entity);
                    }
                }

                if (divisions > 0)
                {
                    foreach (OctreeBox subdiv in subdivs)
                    {
                        subdiv.TestCollisions(entity);
                    }
                }
            }
        }
コード例 #16
0
 // Assign to this box regardless of where this entity fits
 public void ForceAssign(CollisionEntity entity)
 {
     entities.Add(entity);
 }
コード例 #17
0
    //private int cableIndex = 0;

    // Update is called once per frame
    void Update()
    {
        if (!MapUtility.GamePaused)
        {
            if (pickedUpObject != null)
            {
                Vector3 MouseworldPoint = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 65.0f));
                var     currentPosition = grid.GetCellCenterWorld(grid.WorldToCell(new Vector3(MouseworldPoint.x, pickedUpObject.transform.position.y, MouseworldPoint.z)));

                //muri invisibili
                if (currentPosition.x < -400)
                {
                    currentPosition.x = -400;
                }
                if (currentPosition.x > 400)
                {
                    currentPosition.x = 400;
                }

                if (currentPosition.z < -500)
                {
                    currentPosition.z = -500;
                }

                if (currentPosition.z > 500)
                {
                    currentPosition.z = 500;
                }

                //eventuali collisioni vanno controllate solo se
                //Cip sta maneggiando un cavo
                //AND
                //è presente più di un cavo sulla mappa
                if (currentPosition.x != transform.position.x || currentPosition.z != transform.position.z)
                {
                    if (MapUtility.IsChipWiring)//&& MapUtility.Cables.Count >= 2)
                    {
                        if (!MapUtility.IsPositionNearPin(gameObject.transform.position).Item1)
                        {
                            MapUtility.PreventReattaching = false;
                        }

                        var finalPosition = MapUtility.GetBestFinalLocationForMovement(transform.position, currentPosition);
                        transform.position = finalPosition;

                        var cable = MapUtility.Cables.First(cableA => cableA.IsConnectedToCip);
                        cable.Instance.transform.position = finalPosition;
                    }
                    else
                    {
                        //durante il drag, se Chip è vicino ad un pin (e non sta collegando) viene automaticamente attaccato a quest'ultimo
                        //(drop on mobile)
                        if (MapUtility.IsPositionNearPin(currentPosition).Item1)
                        {
                            var pin = MapUtility.IsPositionNearPin(currentPosition).Item2;
                            gameObject.transform.position = new Vector3(pin.AttachmentPoint.Item1.x, 0, pin.AttachmentPoint.Item1.z);
                        }
                        else
                        {
                            transform.position = new Vector3(currentPosition.x, transform.position.y, currentPosition.z);
                        }
                    }
                }
                //rilascio del mouse/pressione touch
                if (Input.GetMouseButtonUp(0))
                {
                    pickedUpObject = null;
                    if (MapUtility.IsPositionNearPin(gameObject.transform.position).Item1)
                    {
                        //Chip vicino ad un pin
                        var pin = MapUtility.IsPositionNearPin(gameObject.transform.position).Item2;
                        if (MapUtility.IsChipWiring && pin.Type.Equals(PinType.Lower) && !pin.IsConnected && !MapUtility.PreventReattaching)
                        {
                            //Il pin vicino a Chip era della fila inferiore e Chip stava trasportando un cavo -> collego il cavo al pin
                            gameObject.transform.position = new Vector3(pin.AttachmentPoint.Item1.x, 0, pin.AttachmentPoint.Item1.z);
                            var cable = MapUtility.Cables.First(cableA => cableA.IsConnectedToCip);
                            cable.Instance.transform.position = pin.AttachmentPoint.Item1 + new Vector3(0, 0, 0);
                            cable.Instance.transform.rotation = pin.AttachmentPoint.Item2;
                            cable.IsConnectedToCip            = false;

                            MapUtility.SetWiring(false);
                            pin.IsConnected    = true;
                            pin.CableConnected = cable;

                            AudioManager.Instance().PlayAttachDetach();
                        }
                        else if (MapUtility.IsChipWiring && pin.Type.Equals(PinType.Upper) && pin.IsConnected) //distruggi cavo
                        {
                            //Il pin vicino a Chip era della fila superiore, Chip sta trasportando un cavo, ed il cavo e' collegato proprio a questo pin -> scollego il cavo
                            MapUtility.setCollisionMap(gameObject.transform.position.x, gameObject.transform.position.z, CollisionEntity.getNoCollisionEntity());
                            gameObject.transform.position = new Vector3(pin.AttachmentPoint.Item1.x, 0, pin.AttachmentPoint.Item1.z + 150);


                            MapUtility.SetWiring(false);
                            pin.IsConnected = false;

                            UnityEngine.Object.Destroy(pin.CableConnected.Instance);
                            MapUtility.Cables.Remove(pin.CableConnected);
                            pin.CableConnected = null;

                            AudioManager.Instance().PlayAttachDetach();
                        }
                        else if (!MapUtility.IsChipWiring && pin.Type.Equals(PinType.Upper) && !pin.IsConnected)
                        {
                            //Il pin vicino a Chip era della fila superiore, Chip non sta trasportando un cavo, ed il pin non ha un cavo collegato -> creo un nuovo cavo che Chip trasportera'
                            gameObject.transform.position  = new Vector3(pin.AttachmentPoint.Item1.x, 0, pin.AttachmentPoint.Item1.z);
                            cablePrefab.transform.position = pin.AttachmentPoint.Item1;
                            var prefabInstance = Instantiate(cablePrefab);
                            prefabInstance.GetComponent <Renderer>().material.color = pin.Instance.GetComponent <Renderer>().material.color;
                            var newCable = new Cable()
                            {
                                Instance         = prefabInstance,
                                IsConnectedToCip = true,
                                index            = pin.Index
                            };

                            MapUtility.Cables.Add(newCable);

                            MapUtility.SetWiring(true);
                            pin.IsConnected    = true;
                            pin.CableConnected = newCable;
                            TrailManager.Instance().addPoint(cablePrefab.transform.position);
                            MapUtility.setCollisionMap(cablePrefab.transform.position.x, cablePrefab.transform.position.z, CollisionEntity.getFullCollisionEntity());
                            AudioManager.Instance().PlayAttachDetach();
                        }
                        else if (!MapUtility.IsChipWiring && pin.Type.Equals(PinType.Lower) && pin.IsConnected) //stacca cavo
                        {
                            //Il pin vicino a Chip era della fila inferiore, Chip non sta trasportando un cavo, ed il pin ha un cavo collegato -> stacco il cavo dal pin e lo faccio trasportare da Chip
                            MapUtility.PreventReattaching = true;
                            MapUtility.SetWiring(true);

                            pin.IsConnected = false;
                            pin.CableConnected.IsConnectedToCip = true;
                            TrailManager.Instance().UpdateCablePointsOnDetach();
                            pin.CableConnected.Instance.transform.position = gameObject.transform.position;

                            GameManager.Instance().CheckForPossibleDepletionPauses(pin);

                            AudioManager.Instance().PlayAttachDetach();
                        }
                    }
                    else if (MapUtility.IsChipWiring && MapUtility.isCollisionOnPointHole(transform.position))
                    {
                        //rilascio avvenuto su un buco mentre Chip stava trasportando un cavo
                        //aquisisco le istanze del buco, del cavo trasportato da chip
                        var chipCable     = MapUtility.Cables.First(cableA => cableA.IsConnectedToCip);
                        var hole          = ((Hole)MapUtility.getCollisionMap(transform.position.x, transform.position.z));
                        var holeConnected = hole.IsConnected;
                        if (holeConnected)
                        {
                            //Se il buco ha un cavo collegato significa che sono ritornato sul buco trasportando il cavo uscente da esso -> scollego/distruggo il cavo
                            hole.IsConnected    = false;
                            hole.CableConnected = null;
                            hole.Exiting(directions.Top);
                            MapUtility.SetWiring(false);

                            UnityEngine.Object.Destroy(chipCable.Instance);
                            MapUtility.Cables.Remove(chipCable);

                            AudioManager.Instance().PlayAttachDetach();
                        }
                        else
                        {
                            //Il buco non ha un cavo collegato -> collego il cavo che sto trasportando al buco
                            chipCable.IsConnectedToCip = false;
                            MapUtility.SetWiring(false);
                            hole.IsConnected    = true;
                            hole.CableConnected = chipCable;
                            AudioManager.Instance().PlayAttachDetach();
                        }
                    }
                    else if (!MapUtility.IsChipWiring && MapUtility.isCollisionOnPointHole(transform.position))
                    {
                        //Chip non trasporta un cavo e rilascio la pressione su un buco
                        //Acquisisco l'istanza del buco su cui Chip si e' fermato
                        Hole newHole = (Hole)MapUtility.getCollisionMap(transform.position.x, transform.position.z);
                        if (!newHole.IsConnected)
                        {
                            Hole connectedHole;

                            try
                            {
                                connectedHole = MapUtility.Holes.First(holeA => holeA.IsConnected == true);
                            }
                            catch (InvalidOperationException)
                            {
                                connectedHole = null;
                            }
                            if (connectedHole != null)
                            {
                                //Controllo se e' presente un buco che ha un cavo collegato -> creo un nuovo cavo e lo collego a Chip
                                cablePrefab.transform.position = transform.position;
                                var prefabInstance = Instantiate(cablePrefab);
                                prefabInstance.GetComponent <Renderer>().material.color = connectedHole.CableConnected.Instance.GetComponent <Renderer>().material.color;
                                var newCable = new Cable()
                                {
                                    Instance         = prefabInstance,
                                    IsConnectedToCip = true,
                                    index            = connectedHole.CableConnected.index
                                };

                                MapUtility.Cables.Add(newCable);

                                MapUtility.SetWiring(true);
                                newHole.IsConnected    = true;
                                newHole.CableConnected = newCable;
                                newHole.cableCreatedOnHole();
                                TrailManager.Instance().addPoint(cablePrefab.transform.position);
                                AudioManager.Instance().PlayAttachDetach();
                            }
                        }
                        else
                        {
                            List <Hole> connectedHoles = MapUtility.Holes.Where(holeA => holeA.IsConnected == true).ToList();
                            if (connectedHoles.Count == 1)
                            {
                                //Il buco su cui Chip si e' fermato e' l'unico collegato -> scollego il cavo e Chip inizia a trasportarlo
                                MapUtility.SetWiring(true);
                                connectedHoles.ElementAt(0).IsConnected = false;
                                connectedHoles.ElementAt(0).CableConnected.IsConnectedToCip = true;
                                connectedHoles.ElementAt(0).CableConnected = null;
                                AudioManager.Instance().PlayAttachDetach();
                            }
                            else if (connectedHoles.ElementAt(0).CableConnected.index != connectedHoles.ElementAt(1).CableConnected.index)
                            {
                                //il buco su cui Chip si e' fermato non e' l'unico ma ci sono cavi diversi collegati ai due buchi -> scollego il cavo
                                MapUtility.SetWiring(true);
                                newHole.IsConnected = false;
                                newHole.CableConnected.IsConnectedToCip = true;
                                newHole.CableConnected = null;
                                AudioManager.Instance().PlayAttachDetach();
                            }
                        }
                    }
                }
            }
            else
            {
                if (Input.GetMouseButton(0))
                {
                    Ray        m_ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit m_hit;
                    bool       result = Physics.Raycast(m_ray, out m_hit);
                    //se l'hit del raycast è troppo lontano da Chip, non aggiorno il transform di Chip
                    //(per evitare teletrasporti di Chip al click sullo schermo)
                    if (result &&
                        Math.Abs(transform.position.x - m_hit.point.x) < 50 && Math.Abs(transform.position.z - m_hit.point.z) < 50)
                    {
                        pickedUpObject = m_hit.transform.gameObject;
                    }
                }
            }
        }
    }
コード例 #18
0
ファイル: Enemy.cs プロジェクト: JazzGlobal/OneRoomRPGJam
 public void Hurt(CollisionEntity player)
 {
     Player p = (Player)player;
     //Take damage based on the player's current attack power.
 }
コード例 #19
0
    void Start()
    {
        //cambia dimensione camera ortografica in base alla dimensione dello schermo in modo da mostrare l'intera board
        camera.orthographicSize = Screen.height * 800 / 1920;


        gm    = this;
        lives = maxLives;
        numberFluxesDepleteded = 0;
        levelCompleted         = false;

        SaveManager.Instance().SaveLastScene(SceneManager.GetActiveScene().name);

        MapUtility.LowerPins = new List <Pin>();
        MapUtility.UpperPins = new List <Pin>();
        MapUtility.Holes     = new List <Hole>();
        MapUtility.Bridges   = new List <Bridge>();

        MapUtility.IsChipWiring = false;

        var lowPins   = MapUtility.GetAllObjectsOnlyInScene().Where(x => x.name.Contains("LPin")).OrderBy(pin => pin.name).ToList();
        var upperPins = MapUtility.GetAllObjectsOnlyInScene().Where(x => x.name.Contains("UPin")).OrderBy(pin => pin.name).ToList();
        var holes     = MapUtility.GetAllObjectsOnlyInScene().Where(x => x.name.Contains("Hole")).OrderBy(hole => hole.name).ToList();
        var bridges   = MapUtility.GetAllObjectsOnlyInScene().Where(x => x.name.Contains("Bridge")).ToList();

        MapUtility.collisionMapBaseSetup();

        //per ogni lowPin trovato, creo un'istanza di Pin
        var pinIndex = 0;

        foreach (var pin in lowPins)
        {
            var attachmentPosition = pin.transform.GetChild(0).position;
            var attachmentRotation = pin.transform.GetChild(0).rotation;
            var attachment         = new Tuple <Vector3, Quaternion>(attachmentPosition, attachmentRotation);

            var pinInstance = new Pin()
            {
                IsConnected     = false,
                Type            = PinType.Lower,
                Instance        = pin,
                AttachmentPoint = attachment,
                Index           = pinIndex
            };
            MapUtility.setCollisionMap(attachmentPosition.x, attachmentPosition.z, CollisionEntity.getFullCollisionEntity());
            MapUtility.LowerPins.Add(pinInstance);
            pinIndex++;
        }

        //per ogni upperPin trovato, creo un'istanza di Pin
        pinIndex = 0;
        foreach (var pin in upperPins)
        {
            var attachmentPosition = pin.transform.GetChild(0).position;
            var attachmentRotation = pin.transform.GetChild(0).rotation;
            var attachment         = new Tuple <Vector3, Quaternion>(attachmentPosition, attachmentRotation);

            var spawnPointPosition = new Vector3(attachmentPosition.x, attachmentPosition.y, attachmentPosition.z - 950);
            var fluxSpawnPoint     = new Tuple <Vector3, Quaternion>(spawnPointPosition, attachmentRotation);

            var pinInstance = new Pin()
            {
                IsConnected     = false,
                Type            = PinType.Upper,
                Instance        = pin,
                FluxSpawnPoint  = fluxSpawnPoint,
                AttachmentPoint = attachment,
                Index           = pinIndex
            };
            MapUtility.setCollisionMap(attachmentPosition.x, attachmentPosition.z, CollisionEntity.getFullCollisionEntity());
            MapUtility.UpperPins.Add(pinInstance);
            pinIndex++;
        }

        idleFluxes      = new List <Flux>();
        depletingFluxes = new List <Flux>();

        //salva i buchi trovati nella scena
        foreach (var hole in holes)
        {
            var holeInstance = new Hole()
            {
                IsConnected = false,
                Instance    = hole
            };

            MapUtility.Holes.Add(holeInstance);
            MapUtility.setCollisionMap(hole.transform.position.x, hole.transform.position.z, holeInstance);
        }

        //salva i ponti trovati nella scena
        foreach (var bridge in bridges)
        {
            var bridgeInstance = new Bridge();
            MapUtility.Bridges.Add(bridgeInstance);
            MapUtility.setCollisionMap(bridge.transform.position.x, bridge.transform.position.z, bridgeInstance);
        }
        //flag per prevenire lo spawn dei flussi, == true nei tutorial
        if (!preventFluxSpawning)
        {
            //il livello 7 prevede la possibilità di spawnare due flussi contemporaneamente su due pin diversi
            if (SceneManager.GetActiveScene().name == "Level 7")
            {
                StartCoroutine(spawnRandomFluxesForeverWithDoubleFlux());
            }
            else
            {
                StartCoroutine(spawnRandomFluxesForever());
            }
        }

        MapUtility.GamePaused = false;
    }
コード例 #20
0
 private void HandleCollisionAdded(CollisionEntity colEntity)
 {
     _collisionList.Add(colEntity);
     _collisionLayer.AddChild(colEntity);
 }
コード例 #21
0
        private void Initilize()
        {
            if (!_initialized)
            {
                Fullscreen();
                _Dimension = GetResolution();
                Size size = new Size((int)(_Dimension[0] * 1.2), (int)(_Dimension[1] * 1.2));
                img = Properties.Resources._3;
                img = CT_Helper.resizeImage(img, size);

                #region Menu
                int   drawingPointWidth  = _Dimension[0] / 2;
                int   drawingPointHeight = _Dimension[1] / 2;
                Point menu = new Point(drawingPointWidth - 683 / 2, drawingPointHeight - 384 / 2);
                menuContainer = new DoubleBufferedPanel(menu);



                menuContainer.Width  = _Dimension[0];
                menuContainer.Height = _Dimension[1];

                menuContainer.Location = new Point(0, 0);
                menuContainer.Name     = "Menu";

                menuHolder = new DoubleBufferedPanel();

                string[] buttonTexts           = { "Starten", "Laden", "Speichern", "Fortsetzen", "Beenden", "Highscore" };
                int      positionMultiplicator = 1;
                int      offset = 10;
                foreach (string text in buttonTexts)
                {
                    VistaButton button = new VistaButton();
                    button.ButtonText = text;

                    button.Width    = 136;
                    button.Height   = 38;
                    button.Location = new Point(offset + button.Width / 4, (button.Height + offset) * positionMultiplicator);
                    menuHolder.Controls.Add(button);
                    positionMultiplicator++;
                    button.Click       += Button_Click;
                    button.KeyDown     += CT_UI_KeyDown;
                    button.KeyUp       += CT_UI_KeyUp;
                    button.BackColor    = Color.Transparent;
                    button.BaseColor    = Color.Transparent;
                    button.ButtonColor  = Color.FromArgb(155, Color.DarkSlateGray);
                    button.GlowColor    = Color.LightGray;
                    button.Font         = new System.Drawing.Font("Pricedown", 16.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    button.CornerRadius = 8;
                }

                this.Controls.Add(menuContainer);
                this.Controls.Add(menuHolder);
                menuHolder.BringToFront();
                menuHolder.BorderStyle  = BorderStyle.Fixed3D;
                menuHolder.Width        = 683;
                menuHolder.Height       = 384;
                menuHolder.Location     = menu;
                menuHolder.BackColor    = Color.Black;
                menuContainer.BackColor = Color.FromArgb(150, Color.Black);

                #endregion

                #region car
                carpanel = new CarPanel(_Dimension);
                //this.Controls.Add(carpanel);
                #endregion

                setCursor();
                this.Focus();

                //Bilderordner angeben
                MapParser.ImagePath = string.Format(@"{0}{1}MapImages", Directory.GetCurrentDirectory(), Path.DirectorySeparatorChar);
                //Karte aus XML laden
                //map = MapParser.Load(@"C:\Users\Bongo\Desktop\Berufsschule\Diagramme AE\Game\CrazyTaxi\testmap.xml");
                map = MapParser.Load(20, 20);
                //Karte vergrößert sich automatisch mit GUI
                //Karte im GUI anzeigen

                //Karte an Größe des GUIs anpassen
                map.Initialize(new Size(_Dimension[0], _Dimension[1]));
                this.BackgroundImage = map.DrawImage(new Size(_Dimension[0], _Dimension[1]));
                this.TransparencyKey = Color.FromArgb(255, 255, 254);
                this.Controls.Add(carpanel);
                map.Collision.SetDebugTarget(this);
                entity = map.Collision.AddEntity(new Size(12, 23));

                _initialized = true;
            }
        }
コード例 #22
0
ファイル: EntityBehaviour.cs プロジェクト: 2kah/arcames
 private void Push(CollisionEntity other)
 {
     other.pushList.Add(this);
 }