Example #1
0
 public void RemoveChildBuilding(BuildingScript bs)
 {
     if ((bs.Type == BuildingType.Field ? gameBuilding.childBuildingField : gameBuilding.childBuildingStorage).Contains(bs.Nr))
     {
         (bs.Type == BuildingType.Field ? gameBuilding.childBuildingField : gameBuilding.childBuildingStorage).Remove(bs.Nr);
     }
 }
Example #2
0
 public void AddChildBuilding(BuildingScript bs)
 {
     if (!(bs.Type == BuildingType.Field ? gameBuilding.childBuildingField : gameBuilding.childBuildingStorage).Contains(bs.Nr))
     {
         (bs.Type == BuildingType.Field ? gameBuilding.childBuildingField : gameBuilding.childBuildingStorage).Add(bs.Nr);
     }
 }
Example #3
0
    void setText()
    {
        currentBuilding = LevelController.me.getBuildingPosIsIn(CommonObjectsStore.player.transform.position);
        currentRoom     = LevelController.me.roomPlayerIsIn;
        string st = "";

        st = SceneManager.GetActiveScene().name + "\n";

        if (currentBuilding == null)
        {
            st += "Outdoors" + "\n";
        }
        else
        {
            st += currentBuilding.buildingName + "\n";
        }
        if (currentRoom == null)
        {
            st += "Outdoors";
        }
        else
        {
            st += currentRoom.roomName;
        }
        myText.text = st;
    }
Example #4
0
    // Use this for initialization
    void Start()
    {
        SmallMultiplesManagerScript smms = GameObject.Find("SmallMultiplesManager").GetComponent <SmallMultiplesManagerScript>();

        ToolTipPrefab    = smms.tooltipPrefab;
        silhouetteShader = smms.silhouetteShader;

        bs = this.transform.parent.parent.parent.GetComponent <BuildingScript>();

        si = transform.Find("sensorInfo").gameObject.GetComponent <SensorInfo>();
        ReadDataFromManager();
        if (hasInfo)
        {
            //si.getMonthlySensorReadings ();
            if (smms.dateType == DateType.Monthly)
            {
                si.getMonthlySensorReadings();
            }
            if (smms.dateType == DateType.Fornightly)
            {
                si.getSensorReadings(smms.smallMultiplesNumber, 14);
            }
            if (smms.dateType == DateType.Weekly)
            {
                si.getSensorReadings(smms.smallMultiplesNumber, 7);
            }
            ChangeColor();
            SendTempTag();
        }
    }
    void SpawnBuildingAndCoins(int x)
    {
        //Building
        float          scaleX       = Random.Range(2, 5);
        float          scaleY       = Random.Range(2, 5.5f);
        BuildingScript building     = Instantiate(buildingPrototype, new Vector2(x, -5 + scaleY / 2), Quaternion.identity);
        Transform      buildingForm = building.gameObject.GetComponent <Transform>();

        buildingForm.localScale = new Vector2(scaleX, scaleY);


        //Coins
        int   nCoins = 0;
        float coinX, coinY;

        while (nCoins < 1)
        {
            coinX = Random.Range(-deltaBuildings / 2, deltaBuildings / 2);
            coinY = Random.Range(-4.8f, 1.8f);

            //make sure the coin does not spawn inside a building
            if (!(coinY < scaleY - 5 + .25 && coinX >= -scaleX / 2 - .25 && coinX <= scaleX / 2 + .25))
            {
                Instantiate(coinPrototype, new Vector2(x + coinX, coinY), Quaternion.identity);
                nCoins++;
            }
        }
    }
Example #6
0
    /// <summary>
    /// Crée un objet Building et renvoie son script
    /// </summary>
    /// <returns>Script du Building créé</returns>
    public static BuildingScript CreateBuilding()
    {
        BuildingScript building = Instantiate(instance.buildingPreFab, Vector3.zero, Quaternion.identity).GetComponent <BuildingScript>();

        building.Initialize();
        return(building);
    }
Example #7
0
 private void NextTile(GameObject obj)
 {
     if (posY + 1 < MANAGER.CityManager.floorOccupied.GetLength(1) && !MANAGER.CityManager.floorOccupied[posX, posY + 1, posZ])
     {
         MANAGER.CityManager.floorOccupied[posX, posY + 1, posZ] = false;
         _child = Instantiate(obj,
                              new Vector3(this.transform.position.x,
                                          this.transform.position.y + (this.gameObject.GetComponent <MeshRenderer>().bounds.size.y / 2),
                                          this.transform.position.z),
                              Quaternion.Euler(this.transform.rotation.x, this.transform.rotation.y, this.transform.rotation.z), this.transform);
         BuildingScript bs = _child.GetComponent <BuildingScript>();
         if (centreMaterial != null)
         {
             bs.centreMaterial = centreMaterial;
         }
         bs.posX          = posX;
         bs.posY          = posY + 1;
         bs.posZ          = posZ;
         bs.currentHeight = currentHeight + 1;
         bs.structures    = structures;
         bs.Build();
     }
     else
     {
         if (posX == MANAGER.CityManager.floorOccupied.GetLength(0) - 1 && posZ == MANAGER.CityManager.floorOccupied.GetLength(2) - 1)
         {
             MANAGER.CityManager.finishedIteration = true;
         }
         Destroy(this);
     }
 }
Example #8
0
    void AttackBuildings()
    {
        if (m_nearbyEnemyBuildings[0] != null)
        {
            //find the closest enemy
            float distance = (m_nearbyEnemyBuildings[0].transform.position - transform.position).magnitude;

            BuildingScript target = m_nearbyEnemyBuildings[0];

            foreach (BuildingScript building in m_nearbyEnemyBuildings)
            {
                float tempDistance = (building.transform.position - transform.position).magnitude;
                if (tempDistance < distance)
                {
                    distance = tempDistance;
                    target   = building;
                }
            }

            if (m_bonusDamage == UnitType.building)
            {
                //deal bonus damage to it
                target.m_health -= m_damage * Time.deltaTime * m_bonusModifer;
            }

            //deal damage to it
            target.m_health -= m_damage * Time.deltaTime;
        }
    }
Example #9
0
 // Update is called once per frame
 void Update()
 {
     if (BaconSauce == null) {
         BaconSauce = (BuildingScript)Instantiate(BuildingTest, new Vector3(0f,55f,0f),Quaternion.identity);
         BaconSauce.SetPlayer(Hunk);
         Hunk.SetBuilding (BaconSauce);
     }
 }
Example #10
0
 void Start()
 {
     foreach (var VARIABLE in GameObject.FindGameObjectsWithTag("Bina"))
     {
         BuildingScript a = VARIABLE.GetComponent <BuildingScript>();
         _buildingScripts.Add(a);
     }
 }
Example #11
0
 public void addNewBuilding(BuildingScript b)
 {
     if (buildingsICreated == null)
     {
         buildingsICreated = new List <BuildingScript> ();
     }
     buildingsICreated.Add(b);
 }
 public static void LoadVillage()
 {
     BuildingScript.DestroyAllBuildings();
     foreach (GameBuilding bd in myGameState.buildingdata)
     {
         BuildManager.SpawnBuilding(bd);
     }
 }
Example #13
0
    // Use this for initialization
    void Start()
    {
        GameObject mapManager = GameObject.FindGameObjectWithTag("MapManager");

        _storeManager    = mapManager.GetComponent <StoreManager>();
        _resourceManager = mapManager.GetComponent <ResourceManager>();
        _buildingScript  = GetComponent <BuildingScript>();
        _built           = false;
    }
Example #14
0
 // Update methods
 private void UpdateReplacing()
 {
     // Update replacing building
     if (replacing != null)
     {
         Destroy(replacing.gameObject);
         UIManager.Instance.OnShowObjectInfo(transform);
         replacing = null;
     }
 }
Example #15
0
 private void ButtonRemoval(BuildingScript buttonRemoved, SignPost signPost)
 {
     for (int i = signPost.buildingList.Count - 1; i >= 0; i--)
     {
         if(signPost.buildingList[i] == buttonRemoved)
         {
             signPost.buildingList.RemoveAt(i);
         }
     }
 }
Example #16
0
    private void Start()
    {
        _building = GetComponent <BuildingScript>();
        _building.SetState(BuildingState.Placing);

        _conditions = new List <IPlaceBuildingCondition>();
        Rigidbody rb = gameObject.AddComponent <Rigidbody>();

        rb.freezeRotation = true;
    }
Example #17
0
 private void Refresh()
 {
     for(int i = 0; i < animalList.Count; i++)
     {
         SelectionScript selection = animalList[i];
     }
     for (int b = 0; b < buildingList.Count; b++)
     {
         BuildingScript buildings = buildingList[b];
     }
 }
Example #18
0
 public void SetNodeObject(Transform transform)
 {
     nodeObject = transform;
     if (nodeObject)
     {
         ho = nodeObject.gameObject.GetComponent <HideableObject>();
         bs = nodeObject.gameObject.GetComponent <BuildingScript>();
     }
     //if(nodeObject && !gameObject.activeSelf) gameObject.SetActive(true);
     //LateUpdate();
 }
Example #19
0
    void Awake()
    {
        if (rectsInBuilding == null || rectsInBuilding.Count == 0)
        {
            rectsInBuilding = new List <roomRect> ();
            roomRect[] rects = this.gameObject.GetComponentsInChildren <roomRect> ();
            foreach (roomRect r in rects)
            {
                rectsInBuilding.Add(r);
            }
        }

        if (isOutdoors == true)
        {
            outdoors = this;
        }

        foreach (roomRect rs in rectsInBuilding)
        {
            Vector3 blPos = rs.bottomLeft.transform.position;
            Vector3 trPos = rs.topRight.transform.position;

            if (blPos.x > trPos.x)
            {
                rs.topRight.transform.position   = blPos;
                rs.bottomLeft.transform.position = trPos;
            }
        }

        if (myRooms == null || myRooms.Count == 0)
        {
            RoomScript[] rooms = FindObjectsOfType <RoomScript> ();
            if (isOutdoors == false)
            {
                foreach (RoomScript r in rooms)
                {
                    if (isObjectInRoom(r.rectsInRoom [0].bottomLeft.gameObject) == true)
                    {
                        addRoomToBuilding(r);
                    }
                }
            }
            else
            {
                foreach (RoomScript r in rooms)
                {
                    if (r.isOutdoors == true)
                    {
                        addRoomToBuilding(r);
                    }
                }
            }
        }
    }
Example #20
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Example #21
0
    public override bool canDo()
    {
        if (myShop == null)
        {
            myShop = this.GetComponent <Shop> ();
        }

        if (myShop.shopAvailable == false)
        {
            return(false);
        }

        if (myBuilding == null)
        {
            myBuilding = LevelController.me.getBuildingPosIsIn(this.gameObject.transform.position);
        }

        if (myController == null)
        {
            myController = this.GetComponent <NPCController> ();
        }

        if (myBuilding == null)
        {
        }
        else
        {
            if (myBuilding.traspassing == true || myBuilding.buildingClosed == true || myShop.robbed == true)
            {
                return(false);
            }
        }



        if (myController == null)
        {
        }
        else
        {
            if (myController.myType == AIType.hostage || myController.knockedDown == true || myController.memory.beenAttacked == true || myController.memory.peopleThatHaveAttackedMe.Contains(CommonObjectsStore.player))
            {
                return(false);
            }
        }

        if (myShop == null)
        {
            return(false);
        }

        return(true);
    }
Example #22
0
    // start moving building
    public static void StartMoving(BuildingScript b)
    {
        // only move building if movable
        if (!b.Movable)
        {
            return;
        }

        Instance.movingBuilding = b;
        placingBuilding         = b.Building;
        StartPlacing();
    }
 private void OnDrawGizmos()
 {
     Gizmos.color = Colour;
     foreach (var b in buildings)
     {
         BuildingScript bs = b.GetComponent <BuildingScript>();//heh
         if (bs != null)
         {
             Gizmos.DrawSphere(b.transform.position, bs.inRadius);
             Gizmos.DrawSphere(b.transform.position, bs.outRadius);
         }
     }
 }
Example #24
0
 void setSiege()
 {
     if (buildingsCalledFrom == null || buildingsCalledFrom.Count == 0)
     {
         buildingUnderSiege = BuildingScript.outdoors;
     }
     else
     {
         buildingUnderSiege = buildingsCalledFrom [0];
         buildingUnderSiege.setBuildingUnderSiege();
     }
     underSiege = true;
     getPointsToSecure();
 }
        public void Build(int xPos, int yPos, int zPos, int x, int y, int z, int height)
        {
            GameObject     build = buildings[Random.Range(0, buildings.Length)];
            GameObject     con   = Instantiate(build, new Vector3((xPos * size), (y * size), (zPos * size)), (Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, ((int)Random.Range(0, 3)) * 90, 0))));
            BuildingScript bs    = con.GetComponent <BuildingScript>();

            bs.structures = buildObjects[Random.Range(0, buildObjects.Length)];
            bs.posX       = x;
            bs.posY       = y;
            bs.posZ       = z;
            bs.scale      = size;
            bs.maxHeight  = height;
            bs.Build();
        }
Example #26
0
    public void updateUI(GameObject obj)
    {
        BuildingScript buildingData = obj.GetComponent <BuildingScript>();

        Debug.Log(buildingData.data.name);
        UIText.text    = buildingData.data.name;
        UIPurpose.text = buildingData.data.purpose;

        double comsumption = System.Math.Truncate(buildingData.data.calculateLatestDailyConsumption());

        UIkWh.text = PPWithCommas(comsumption.ToString());
        UIBTU.text = PPWithCommas((comsumption * 3412.0).ToString());
        UIGas.text = PPWithCommas((System.Math.Truncate(comsumption / 33.4)).ToString());
    }
Example #27
0
    private void populateMap()
    {
        foreach (var building in buildings)
        {
            BuildingScript BS = Instantiate <BuildingScript>(prefab);
            BS.data = building.Value;

            //scale the latitude and lonitude
            float x = (float)((40.1 - building.Value.latitude) * 5000.0) - 350f;
            float y = (float)((-83.03 - building.Value.longitude) * 5000.0) + 50f;

            Vector3 pos = new Vector3(y, 0.4f, x);
            BS.gameObject.transform.position = pos;
        }
    }
Example #28
0
    void SpawnBuilding()
    {
        buildingPanel = GameObject.Find("BuildingPanel");
        bp            = buildingPanel.GetComponent <BuildingScript>();
        resources     = GameObject.Find("Resources");
        rm            = resources.GetComponent <ResourcesManager> ();

        GameObject building = (GameObject)Instantiate(buildFab[bp.buildingSelection], transform.position, transform.rotation);

        if (ss.stage == 1)
        {
            building.tag = "P1Building";
        }
        else if (ss.stage == 2)
        {
            building.tag = "P2Building";
        }

        if (bp.buildingSelection == 0)
        {
            building.name = "solar";
        }
        else if (bp.buildingSelection == 1)
        {
            building.name = "gas";
        }
        else if (bp.buildingSelection == 2)
        {
            building.name = "nul";
        }
        else if (bp.buildingSelection == 3)
        {
            building.name = "coal";
        }
        else if (bp.buildingSelection == 4)
        {
            building.name = "wind";
        }
        else if (bp.buildingSelection == 5)
        {
            building.name = "oil";
        }
        building.transform.parent         = transform;
        building.transform.localPosition += new Vector3(0, 1.5f, 0);

        rm.calcTrigger = true;
        ls.logContent  = "";
    }
 public virtual void OnPadClicked(ClickedEventArgs e)
 {
     if (PadClicked != null)
     {
         PadClicked(this, e);
     }
     if (this.name.Equals("Controller (left)"))
     {
         for (int i = 1; i <= smallMultipleNumbers; i++)
         {
             GameObject building = GameObject.Find("Building " + i);
             buildS = building.transform.GetChild(0).gameObject.GetComponent <BuildingScript>();
             buildS.ChangeExplosion();
         }
     }
 }
    public void ResourceCost()
    {
        if (calcTrigger)
        {
            buildingPanel = GameObject.Find("BuildingPanel");
            bp            = buildingPanel.GetComponent <BuildingScript>();


            if (bp.buildingSelection == 0)
            {
                SolarSelected();
            }
            else if (bp.buildingSelection == 1)
            {
                GasSelected();
            }
            else if (bp.buildingSelection == 2)
            {
                NulclearSelected();
            }
            else if (bp.buildingSelection == 3)
            {
                CoalMineSelected();
            }
            else if (bp.buildingSelection == 4)
            {
                WindTurbSelected();
            }
            else if (bp.buildingSelection == 5)
            {
                OilRigSelected();
            }

            if (ss.stage == 1)
            {
                ss.stage = 2;
            }
            else if (ss.stage == 2)
            {
                ss.stage    = 3;
                onceTrigger = true;
            }

            bp.buildingSelection = -1;
            calcTrigger          = false;
        }
    }
Example #31
0
    void Start()
    {
        bScript = GameObject.Find("GameManager").GetComponent <BuildingScript>();


        Button switchButton = SwitchButton.GetComponent <Button>();

        switchButton.onClick.AddListener(SwitchButtonClick);

        Button cableButton = CableButton.GetComponent <Button>();

        cableButton.onClick.AddListener(CableButtonClick);

        Button trashButton = TrashButton.GetComponent <Button>();

        trashButton.onClick.AddListener(TrashButtonClick);
    }
Example #32
0
 public void SetBuilding(BuildingScript DasBuiliding)
 {
     TheBuilding = DasBuiliding;
 }
Example #33
0
    void OnTriggerEnter2D(Collider2D otherCollider)
    {
        isKilled = false;
        myTimer2 = 1;
        Tigh myTigh = otherCollider.gameObject.GetComponent<Tigh> ();
        CoinScript myCoin = otherCollider.gameObject.GetComponent<CoinScript> ();
        BombScript myBomb = otherCollider.gameObject.GetComponent<BombScript> ();
        myBuilding = otherCollider.gameObject.GetComponent<BuildingScript> ();
        EnemyScript bat = otherCollider.gameObject.GetComponent<EnemyScript> ();
        if (myTigh != null) {
                if (isPowerUp) {
                    Destroy (myTigh.gameObject);
                    return;
                }
                Destroy (this.gameObject);
                //transform.Rotate(90,0,0,Space.Self);
                //	Destroy(myTigh.gameObject);
            }

            if (myCoin != null) {
            Coin.setNumberOfCoins(Coin.getNumberOfCoins()+1);
                this.powerUpBar++;
                if (!isPowerUp ) {
                    audio.clip = coin;
                    audio.Play ();
                }
                Destroy (myCoin.gameObject);
            }

            if (bat != null) {
                if (isPowerUp) {
                    Destroy (bat.gameObject);
                    return;
                }
                //Destroy (this.gameObject);
            }
    }
Example #34
0
 // Use this for initialization
 void Start()
 {
     myBuildingScript = transform.parent.transform.parent.GetComponent<BuildingScript> ();
     currentTime = 0;
     productionCompleteTime = myBuildingScript.bType.pTime;
 }