Exemplo n.º 1
0
        public bool SimilarItemNextToTile(Compass Compass, Building.Building building)
        {
            if (building.GetPrimitiveObject().GetBuildingType() == BuildingType.Infrastructure)
            {
                Tile t = GetNeighbour(Compass);
                if (t != null)
                {
                    Building.Building neighbourBuilding = t.GetInfrastructureItem();
                    if (neighbourBuilding != null && neighbourBuilding.GetPrimitiveObject().GetBuildingCategory() == building.GetPrimitiveObject().GetBuildingCategory())
                    {
                        return(true);
                    }
                }
            }
            else if (building.GetPrimitiveObject().GetBuildingType() == BuildingType.Gameplay)
            {
                Tile t = GetNeighbour(Compass);
                if (t != null)
                {
                    Building.Building neighbourBuilding = t.GetGameplayItem();
                    if (neighbourBuilding != null && neighbourBuilding.GetPrimitiveObject().GetBuildingCategory() == building.GetPrimitiveObject().GetBuildingCategory())
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        public static Building.Building Create(string name, int positionX, int positionY, int sizeX, int sizeY)
        {
            Building.PrimitiveBuilding primitive;
            switch (name.ToLower())
            {
            case "wall":
                primitive = new Building.Infrastructure.ConcreteWall();
                break;

            case "carpet":
                primitive = new Building.Infrastructure.CarpetFloorOne();
                break;

            case "floor":
                primitive = new Building.Infrastructure.ConcreteFloorOne();
                break;

            default:
                Nez.Console.DebugConsole.instance.log("Lua is trying to load a object that doesnt exist: " + name);
                return(null);
            }

            Entity entity = World.WorldController.SCENE.createEntity("Building at x: " + positionX + " y: " + positionY);

            Building.Building building = new Building.Building();
            entity.addComponent(building);
            building.SetPrimitiveBuilding(primitive);
            building.SetInfo(new Vector2(positionX, positionY), new Vector2(sizeX, sizeY));

            return(building);
        }
Exemplo n.º 3
0
 public Score(Game game, Building.Building building)
 {
     _game                = game;
     _building            = building;
     _peopleKilled        = 0;
     _overallStress       = 0.0;
     HighestOverallStress = 0.0;
 }
 void OnCollisionEnter2D(Collision2D other)
 {
     Building.Building building = other.gameObject.GetComponent <Building.Building>();
     if (building != null)
     {
         HealthSystem healthSystem = building.GetComponent <HealthSystem>();
         healthSystem.Damage(10);
         Destroy(gameObject);
     }
 }
Exemplo n.º 5
0
        public int SimilarConstructedItemsAroundTile(Building.Building building)
        {
            Compass[] Compasss      = { Compass.N, Compass.E, Compass.S, Compass.W };
            int       similarAmount = 0;

            if (building.GetPrimitiveObject().GetBuildingType() == BuildingType.Infrastructure)
            {
                foreach (Compass d in Compasss)
                {
                    Tile t = GetNeighbour(d);
                    if (t != null)
                    {
                        if (t.GetInfrastructureItem() != null && t.GetInfrastructureItem().GetPrimitiveObject().GetBuildingCategory() == building.GetPrimitiveObject().GetBuildingCategory())
                        {
                            if (t.GetInfrastructureItem().IsConstructed(t.GetTileNumber(), true))
                            {
                                similarAmount++;
                            }
                        }
                    }
                }
            }
            else if (building.GetPrimitiveObject().GetBuildingType() == BuildingType.Gameplay)
            {
                foreach (Compass d in Compasss)
                {
                    Tile t = GetNeighbour(d);
                    if (t != null)
                    {
                        if (t.GetGameplayItem() != null && t.GetGameplayItem().GetPrimitiveObject().GetBuildingCategory() == building.GetPrimitiveObject().GetBuildingCategory())
                        {
                            if (t.GetGameplayItem().IsConstructed(t.GetTileNumber(), true))
                            {
                                similarAmount++;
                            }
                        }
                    }
                }
            }

            return(similarAmount);
        }
Exemplo n.º 6
0
        public Person(Game game, Building.Building building, double stressMultiplier)
            : base(game, SPRITES[RandomHelper.RandomInt(0, SPRITES.Length - 1)], new Rectangle(0, 0, 32, 32))
        {
            IsEnabled = true;

            _stressMultiplier = stressMultiplier;

            _game             = game;
            _building         = building;
            _textParticles    = new List <TextParticle>();
            _disposeParticles = new LinkedList <TextParticle>();
            VisitedFloors     = new HashSet <int>();

            CreateAnimations();
            SourceRectangle = Animations[CurrentAnimation].CurrentFrame;

            int x = RandomHelper.RandomInt(0, _building.Rooms - 1);
            int y = RandomHelper.RandomInt(0, _building.Floors - 1);

            if (x == building.ShaftPosition)
            {
                if (RandomHelper.RandomBool())
                {
                    x++;
                }
                else
                {
                    x--;
                }
            }

            Spawn(new Point(x, y));
            SetNewDestination();

            _isTraveling = false;
            IsExploring  = false;
        }
        void LookForTargets()
        {
            float targetMaxRadius = 10f;

            Collider2D[] collider2DArray = Physics2D.OverlapCircleAll(transform.position, targetMaxRadius);

            foreach (Collider2D collider2D in collider2DArray)
            {
                Building.Building building = collider2D.GetComponent <Building.Building>();
                if (building != null)
                {
                    //It's a building!
                    if (_targetTransform == null)
                    {
                        _targetTransform = building.transform;
                    }
                    else
                    {
                        if (Vector3.Distance(transform.position, building.transform.position) <
                            Vector3.Distance(transform.position, _targetTransform.transform.position))
                        {
                            // New Building is closer!
                            _targetTransform = building.transform;
                        }
                    }
                }
            }

            if (_targetTransform == null)
            {
                // Found no targets within range;
                if (BuildingManager.Instance.GetHqBuilding() != null)
                {
                    _targetTransform = BuildingManager.Instance.GetHqBuilding().transform;
                }
            }
        }
Exemplo n.º 8
0
 public void SetInfrastructureItem(Building.Building item)
 {
     this.infrastructureItem = item;
     onInfrastructureObjectChanged?.Invoke(this);
 }
Exemplo n.º 9
0
 public void SetGameplayItem(Building.Building item)
 {
     this.gameplayItem = item;
     onGameplayObjectChanged?.Invoke(this);
 }
Exemplo n.º 10
0
        private void SetFromDifficulty(int difficulty)
        {
            int    persons, floors, rooms;
            double stressMultiplier;

            switch (difficulty)
            {
            case 1:
                persons = RandomHelper.RandomInt(1, 2);
                floors  = RandomHelper.RandomInt(5, 8);
                rooms   = 8;
                break;

            case 2:
                persons = RandomHelper.RandomInt(2, 3);
                floors  = RandomHelper.RandomInt(5, 8);
                rooms   = 8;
                break;

            case 3:
                persons = RandomHelper.RandomInt(3, 4);
                floors  = RandomHelper.RandomInt(5, 7);
                rooms   = RandomHelper.RandomInt(8, 10);
                break;

            case 4:
                persons = RandomHelper.RandomInt(3, 8);
                floors  = RandomHelper.RandomInt(5, 13);
                rooms   = RandomHelper.RandomInt(8, 10);
                break;

            case 5:
                persons = RandomHelper.RandomInt(5, 8);
                floors  = RandomHelper.RandomInt(5, 15);
                rooms   = RandomHelper.RandomInt(8, 16);
                break;

            case 6:
                persons = RandomHelper.RandomInt(5, 10);
                floors  = RandomHelper.RandomInt(5, 13);
                rooms   = RandomHelper.RandomInt(8, 20);
                break;

            case 7:
                persons = RandomHelper.RandomInt(7, 12);
                floors  = RandomHelper.RandomInt(5, 17);
                rooms   = RandomHelper.RandomInt(8, 20);
                break;

            case 8:
                persons = RandomHelper.RandomInt(10, 15);
                floors  = RandomHelper.RandomInt(5, 20);
                rooms   = RandomHelper.RandomInt(8, 20);
                break;

            case 9:
                persons = 3;
                floors  = 5;
                rooms   = 12;
                break;

            default:     // after round 9
                persons = RandomHelper.RandomInt(5, 15);
                floors  = RandomHelper.RandomInt(5, 20);
                rooms   = RandomHelper.RandomInt(5, 20);
                break;
            }

            if (difficulty < 9)
            {
                stressMultiplier  = 1 / (double)difficulty;
                stressMultiplier *= 3;
            }
            else
            {
                stressMultiplier = (1 / 9.0) * 3;

                int topLevel = difficulty - 10;
                if (topLevel < 12)
                {
                    _timer = new TimeSpan(0, 0, (int)(_timer.TotalSeconds - (topLevel * 5)));
                }
                else
                {
                    _timer = new TimeSpan(0, 1, 30);
                }
            }

            _building = new Building.Building(Game, floors, rooms, persons, stressMultiplier, difficulty);
        }
Exemplo n.º 11
0
 public void setCurrentBuilding(Building.Building building)
 {
     CurrentBuilding = building;
 }