Esempio n. 1
0
 private void ChoosePropertyByPlayer(Ownable property)
 {
     _choosenProperty = property;
     ChooseProperty.SetActive(false);
     Question.gameObject.SetActive(true);
     ShowQuestion();
 }
Esempio n. 2
0
 public void TransfermortgagedPropertyBetweenPlayers(Player from, Player to, Ownable property)
 {
     from.Mortgaged.Remove(property);
     to.Mortgaged.Add(property);
     property.SetOwner(to);
     TextLog.LogText(string.Format("{0} передаётся от игрока {1} к игроку {2}", property.name, from.PlayerName, to.PlayerName));
 }
Esempio n. 3
0
 void ButtonPressed(Ownable property)
 {
     _action(property);
     if (_needUpdateAfterClick)
     {
         UpdateList(property);
     }
 }
Esempio n. 4
0
 public void MortgageProperty(Ownable property)
 {
     CurrentPlayer.BalanceManager.GiveMoneyToPlayer(property.PurchasePrice / 2);
     CurrentPlayer.Owned.Remove(property);
     CurrentPlayer.Mortgaged.Add(property);
     property.Mortgage();
     TextLog.LogText(string.Format("{0} закладывает {1}", CurrentPlayer.PlayerName, property.name));
 }
    public override void DoPostConfigureComplete(GameObject go)
    {
        GeneratedBuildings.RegisterLogicPorts(go, INPUT_PORTS, OUTPUT_PORTS);
        Ownable ownable = go.AddOrGet <Ownable>();

        ownable.slotID      = Db.Get().AssignableSlots.RocketCommandModule.Id;
        ownable.canBePublic = false;
        EntityTemplates.ExtendBuildingToRocketModule(go);
    }
Esempio n. 6
0
    public void ShowAllInRadarRange(Ownable owned)
    {
        var cellsInRange = CellsInRange(owned.transform.position, owned.RadarRange);

        foreach (HexCell cell in cellsInRange)
        {
            cell.Discover(owned);
        }
    }
Esempio n. 7
0
 public bool CheckDistance(Ownable target)
 {
     if (target != null)
     {
         float distance = Vector3.Distance(target.transform.position, this.transform.position);
         return(distance < 10.0 ? true : false);
     }
     return(false);
 }
Esempio n. 8
0
 public void BuyProperty(Ownable property)
 {
     if (!CurrentPlayer.BalanceManager.GetMoneyFromPlayer(property.PurchasePrice))
     {
         return;
     }
     TextLog.LogText(string.Format("{0} покупает {1}", CurrentPlayer.PlayerName, property.name));
     CurrentPlayer.Owned.Add(property);
     property.SetOwner(CurrentPlayer);
 }
Esempio n. 9
0
 public void Lose(Ownable thing)
 {
     if (thing is Planet)
     {
         planets.Remove(thing);
     }
     if (thing is Spaceship)
     {
         spaceships.Remove(thing);
     }
 }
Esempio n. 10
0
 public void Own(Ownable thing)
 {
     if (thing is Planet)
     {
         planets.Add(thing);
     }
     if (thing is Spaceship)
     {
         spaceships.Add(thing);
     }
 }
Esempio n. 11
0
 public void RedeemProperty(Ownable property)
 {
     if (!CurrentPlayer.BalanceManager.GetMoneyFromPlayer((int)(property.PurchasePrice / 2 * 1.1f)))
     {
         return;
     }
     CurrentPlayer.Owned.Add(property);
     CurrentPlayer.Mortgaged.Remove(property);
     property.UnMortgage();
     TextLog.LogText(string.Format("{0} выкупает {1}", CurrentPlayer.PlayerName, property.name));
 }
Esempio n. 12
0
    public void Discover(Ownable owned)
    {
        visibleByList.Add(owned);
        discoveredBy.Add(owned.GetOwner());

        State = EHexState.Visible;
        if (!IsEmpty())
        {
            ObjectInCell.SetActive(true);
        }
        gameObject.GetComponentInChildren <MeshRenderer>().material = VisibleMaterial;
    }
Esempio n. 13
0
    private void Awake()
    {
        instance = this;

        for (int i = 0; i < DeskObjects.Count; ++i)
        {
            Ownable buyable = (Ownable)DeskObjects[i].GetComponentInChildren(typeof(Ownable));
            if (buyable != null)
            {
                BuyableDeskObjects.Add(buyable);
            }
        }
    }
Esempio n. 14
0
 public static void Postfix(Ownable __instance)
 {
     try
     {
         if (IsOwned(__instance))
         {
             Painter.ApplyColorToKAnimControllerBase(__instance);
         }
     }
     catch (Exception e)
     {
         State.Common.Logger.LogOnce("Ownable_UpdateTint.Postfix", e);
     }
 }
    public IEnumerator OfferPurchase(Ownable ownable)
    {
        decisionMade = false;

        deedImage.sprite = ownable.deed;
        transform.GetChild(0).gameObject.SetActive(true);

        while (!decisionMade)
        {
            yield return(null);
        }

        transform.GetChild(0).gameObject.SetActive(false);
    }
Esempio n. 16
0
            public static void Postfix(Ownable __instance)
            {
                Color color = ColorHelper.GetComponentMaterialColor(__instance);
                bool  owned = __instance.assignee != null;

                if (owned)
                {
                    KAnimControllerBase animBase = __instance.GetComponent <KAnimControllerBase>();
                    if (animBase != null)
                    {
                        animBase.TintColour = color;
                    }
                }
            }
Esempio n. 17
0
    void BuildElement(Ownable property) // создание нового элемента и настройка параметров
    {
        RectTransform clone = Instantiate(element) as RectTransform;

        clone.SetParent(scroll.content);
        clone.localScale       = Vector3.one;
        clone.anchoredPosition = new Vector2(e_Pos.x, e_Pos.y - curY);
        ItemButton item = clone.GetComponent <ItemButton>();

        item.mainButtonText.text = property.name;
        item.property            = property;
        item.mainButton.onClick.AddListener(() => ButtonPressed(property));
        buttons.Add(clone);
    }
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.AddOrGet <LoopingSounds>();
        go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.Toilet, false);
        go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.FlushToilet, false);
        FlushToilet flushToilet = go.AddOrGet <FlushToilet>();

        flushToilet.massConsumedPerUse    = 5f;
        flushToilet.massEmittedPerUse     = 11.7f;
        flushToilet.newPeeTemperature     = 310.15f;
        flushToilet.diseaseId             = "FoodPoisoning";
        flushToilet.diseasePerFlush       = 100000;
        flushToilet.diseaseOnDupePerFlush = 5000;
        KAnimFile[] overrideAnims = new KAnimFile[1]
        {
            Assets.GetAnim("anim_interacts_toiletflush_kanim")
        };
        ToiletWorkableUse toiletWorkableUse = go.AddOrGet <ToiletWorkableUse>();

        toiletWorkableUse.overrideAnims       = overrideAnims;
        toiletWorkableUse.workLayer           = Grid.SceneLayer.BuildingFront;
        toiletWorkableUse.resetProgressOnStop = true;
        ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

        conduitConsumer.conduitType        = ConduitType.Liquid;
        conduitConsumer.capacityTag        = ElementLoader.FindElementByHash(SimHashes.Water).tag;
        conduitConsumer.capacityKG         = 5f;
        conduitConsumer.wrongElementResult = ConduitConsumer.WrongElementResult.Store;
        ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

        conduitDispenser.conduitType         = ConduitType.Liquid;
        conduitDispenser.invertElementFilter = true;
        conduitDispenser.elementFilter       = new SimHashes[1]
        {
            SimHashes.Water
        };
        Storage storage = go.AddOrGet <Storage>();

        storage.capacityKg        = 25f;
        storage.doDiseaseTransfer = false;
        storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
        Ownable ownable = go.AddOrGet <Ownable>();

        ownable.slotID      = Db.Get().AssignableSlots.Toilet.Id;
        ownable.canBePublic = true;
        RequireOutputs requireOutputs = go.AddOrGet <RequireOutputs>();

        requireOutputs.ignoreFullPipe = true;
    }
Esempio n. 19
0
 public void SetProperty(Ownable property)
 {
     Property = property;
     if (property.Owner1 != null)
     {
         Owner.text = string.Format("Владелец - {0}", property.Owner1.PlayerName);
         Rent.text  = string.Format("Текущая аренда - {0}", property.Rent());
     }
     else
     {
         Owner.text = "Нет владельца";
         Rent.text  = string.Format("Минимальная аренда - {0}", property.Rent());
     }
     Image.sprite = Property.Image;
 }
Esempio n. 20
0
    public void UpdateInRadarRange(Ownable owned, Vector3 oldPosition)
    {
        var cellsInOldRadar = CellsInRange(oldPosition, owned.RadarRange);
        var cellsInRadar    = CellsInRange(owned.transform.position, owned.RadarRange);

        foreach (HexCell cell in cellsInOldRadar.Except(cellsInRadar))
        {
            cell.Hide(owned);
        }

        foreach (HexCell cell in cellsInRadar.Except(cellsInOldRadar))
        {
            cell.Discover(owned);
        }
    }
Esempio n. 21
0
        private static bool TryApplyTintViaOwnable(Ownable ownable, Color targetColor)
        {
            try
            {
                Traverse.Create(ownable).Field("ownedTint").SetValue(targetColor);
                Traverse.Create(ownable).Method("UpdateTint").GetValue();

                return(true);
            }
            catch (Exception e)
            {
                State.Common.Logger.Log("Failed to apply tint via ownable", e);
            }

            return(false);
        }
Esempio n. 22
0
    public void Attack()
    {
        var     spaceship = EventManager.selectionManager.SelectedObject.GetComponent <Spaceship>();
        Ownable target    = EventManager.selectionManager.TargetObject.GetComponent <Ownable>();

        if (spaceship != null && spaceship.GetActionPoints() > 0 && target != null)

        {
            if (spaceship.Attack(target))
            {
                Debug.Log("You attacked");
                spaceship.SetActionPoints(-1);
            }
        }
        Thread.Sleep(150);
    }
    public void OnPrefabInit(GameObject inst)
    {
        GeneShuffler component = inst.GetComponent <GeneShuffler>();

        component.workLayer = Grid.SceneLayer.Building;
        Ownable component2 = inst.GetComponent <Ownable>();

        component2.slotID = Db.Get().AssignableSlots.GeneShuffler.Id;
        OccupyArea component3 = inst.GetComponent <OccupyArea>();

        component3.objectLayers = new ObjectLayer[1]
        {
            ObjectLayer.Building
        };
        inst.GetComponent <Deconstructable>();
    }
Esempio n. 24
0
        //[HarmonyPatch(typeof(ManualGenerator))]
        //[HarmonyPatch("OnPrefabInit")]
        //public static class ManualGenerator_OnPrefabInit
        //{
        //    public static void Postfix(ManualGenerator __instance)
        //    {
        //        TryAddOwnable(__instance.gameObject);
        //    }
        //}

        private static void TryAddOwnable(GameObject go)
        {
            string defName = go.GetComponent <Building>().Def.PrefabID;

            if (Db.Get().AssignableSlots.Exists(defName))
            {
                Ownable ownable = go.AddOrGet <Ownable>();
                ownable.slotID      = defName;
                ownable.canBePublic = true;
                ownable.AddAutoassignPrecondition(CanAutoAssignTo);
            }
            else if (!WarningTable.Contains(defName))
            {
                Debug.LogWarning($"[AssignableMachines] Cannot assign Ownable! No Database AssignableSlots definition for: {defName}.");
                WarningTable.Add(defName);
            }
        }
Esempio n. 25
0
    void UpdateList(Ownable property)             // функция удаления элемента
    {
        vPos = scroll.verticalNormalizedPosition; // запоминаем позицию скролла
        var item = buttons.Find(x => x.GetComponent <ItemButton>().property == property);

        Destroy(item.GetComponent <ItemButton>().gameObject); // удаляем этот элемент из списка
        buttons.Remove(item);                                 // удаляем этот элемент из массива
        curY = 0;
        size--;                                               // минус один элемент
        RectContent();                                        // пересчитываем размеры окна
        foreach (RectTransform b in buttons)                  // сдвигаем элементы
        {
            b.anchoredPosition = new Vector2(e_Pos.x, e_Pos.y - curY);
            curY += delta.y;
        }
        scroll.verticalNormalizedPosition = vPos; // возвращаем позицию скролла
    }
    public override void DoPostConfigureComplete(GameObject go)
    {
        go.GetComponent <KAnimControllerBase>().initialAnim = "off";
        go.GetComponent <KPrefabID>().AddTag(TagManager.Create("Bed"), false);
        Clinic clinic = go.AddOrGet <Clinic>();

        clinic.doctorVisitInterval = 300f;
        clinic.workerInjuredAnims  = new KAnimFile[1]
        {
            Assets.GetAnim("anim_healing_bed_kanim")
        };
        clinic.workerDiseasedAnims = new KAnimFile[1]
        {
            Assets.GetAnim("anim_interacts_med_cot_sick_kanim")
        };
        clinic.workLayer = Grid.SceneLayer.BuildingFront;
        string text  = "MedicalCot";
        string text2 = "MedicalCotDoctored";

        clinic.healthEffect              = text;
        clinic.doctoredHealthEffect      = text2;
        clinic.diseaseEffect             = text;
        clinic.doctoredDiseaseEffect     = text2;
        clinic.doctoredPlaceholderEffect = "DoctoredOffCotEffect";
        RoomTracker roomTracker = go.AddOrGet <RoomTracker>();

        roomTracker.requiredRoomType   = Db.Get().RoomTypes.Hospital.Id;
        roomTracker.requirement        = RoomTracker.Requirement.CustomRecommended;
        roomTracker.customStatusItemID = Db.Get().BuildingStatusItems.ClinicOutsideHospital.Id;
        Sleepable sleepable = go.AddOrGet <Sleepable>();

        sleepable.overrideAnims = new KAnimFile[1]
        {
            Assets.GetAnim("anim_interacts_med_cot_sick_kanim")
        };
        DoctorChoreWorkable doctorChoreWorkable = go.AddOrGet <DoctorChoreWorkable>();

        doctorChoreWorkable.overrideAnims = new KAnimFile[1]
        {
            Assets.GetAnim("anim_interacts_med_cot_doctor_kanim")
        };
        doctorChoreWorkable.workTime = 45f;
        Ownable ownable = go.AddOrGet <Ownable>();

        ownable.slotID = Db.Get().AssignableSlots.Clinic.Id;
    }
Esempio n. 27
0
    public IEnumerator StartAuction(Ownable property, Player abandonedPlayer)
    {
        this.gameObject.SetActive(true);
        _property   = property;
        _maxBid     = property.PurchasePrice;
        MaxBid.text = string.Format("Текущая стоимость: {0}Р", _maxBid);
        foreach (var player in _gameManager.ActivePlayers)
        {
            if (!player.Equals(abandonedPlayer))
            {
                _activePlayers.Add(player);
            }
        }
        yield return(StartCoroutine(StartBidding()));

        this.gameObject.SetActive(false);
        _gameManager.State = GameManager.States.Default;
    }
Esempio n. 28
0
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false);
        go.AddTag(GameTags.NotRoomAssignable);
        go.AddOrGet <BuildingComplete>().isManuallyOperated = true;
        Prioritizable.AddRef(go);
        Ownable ownable = go.AddOrGet <Ownable>();

        ownable.slotID = Db.Get().AssignableSlots.ResetSkillsStation.Id;
        ResetSkillsStation resetSkillsStation = go.AddOrGet <ResetSkillsStation>();

        resetSkillsStation.workTime      = 180f;
        resetSkillsStation.overrideAnims = new KAnimFile[1]
        {
            Assets.GetAnim("anim_interacts_reSpeccer_kanim")
        };
        resetSkillsStation.workLayer = Grid.SceneLayer.BuildingFront;
    }
Esempio n. 29
0
    public override void DoPostConfigureComplete(GameObject go)
    {
        go.GetComponent <KAnimControllerBase>().initialAnim = "off";
        Ownable ownable = go.AddOrGet <Ownable>();

        ownable.slotID = Db.Get().AssignableSlots.MessStation.Id;
        Storage storage = BuildingTemplates.CreateDefaultStorage(go, false);

        storage.showInUI   = true;
        storage.capacityKg = TableSaltTuning.SALTSHAKERSTORAGEMASS;
        ManualDeliveryKG manualDeliveryKG = go.AddOrGet <ManualDeliveryKG>();

        manualDeliveryKG.SetStorage(storage);
        manualDeliveryKG.requestedItemTag = TableSaltConfig.ID.ToTag();
        manualDeliveryKG.capacity         = TableSaltTuning.SALTSHAKERSTORAGEMASS;
        manualDeliveryKG.refillMass       = TableSaltTuning.CONSUMABLE_RATE;
        manualDeliveryKG.choreTypeIDHash  = Db.Get().ChoreTypes.FoodFetch.IdHash;
        manualDeliveryKG.ShowStatusItem   = false;
    }
Esempio n. 30
0
 public void AddToList(Ownable property, bool resetScrollbar)
 {
     element.gameObject.SetActive(true);
     vPos = scroll.verticalNormalizedPosition;
     curY = 0;
     size++;
     RectContent();
     foreach (RectTransform b in buttons)
     {
         b.anchoredPosition = new Vector2(e_Pos.x, e_Pos.y - curY);
         curY += delta.y;
     }
     BuildElement(property);
     if (!resetScrollbar)
     {
         scroll.verticalNormalizedPosition = vPos;
     }
     element.gameObject.SetActive(false);
 }