/// <summary>Builds this Item</summary>
        protected override void Build()
        {
            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;

            // Load Components
            SpawnResource spawn = Prefab.GetComponent <SpawnResource>();

            // Setup Components
            spawn.id                  = ID;
            spawn.ObjectsToSpawn      = GameContext.Instance.LookupDirector.GetPrefabs(ToSpawn);
            spawn.BonusObjectsToSpawn = BonusToSpawn != null?GameContext.Instance.LookupDirector.GetPrefabs(BonusToSpawn) : new GameObject[0];

            spawn.MaxObjectsSpawned         = MaxObjectsSpawned;
            spawn.MinObjectsSpawned         = MinObjectsSpawned;
            spawn.MinNutrientObjectsSpawned = MinNutrientObjectsSpawned == -1 ? MaxObjectsSpawned : MinNutrientObjectsSpawned;
            spawn.MinSpawnIntervalGameHours = MinSpawnIntervalGameHours;
            spawn.MaxSpawnIntervalGameHours = MaxSpawnIntervalGameHours;
            spawn.BonusChance        = BonusChance;
            spawn.minBonusSelections = MinBonusSelections;

            // Builds the Spawn Points
            BuildSpawnPoints(spawn);
        }
示例#2
0
        /// <summary>
        /// Adds a new spawn point
        /// </summary>
        /// <param name="pos">Position to add at</param>
        /// <param name="rot">Rotation to add with</param>
        protected void AddSpawnpoint(Vector3 pos, Vector3 rot)
        {
            SpawnResource spawn = Prefab.GetComponent <SpawnResource>();

            GameObject joint = Object.Instantiate(spawn.SpawnJoints[0].gameObject, pos, Quaternion.Euler(rot), spawn.transform);

            joint.name = "SpawnJoint" + spawn.SpawnJoints.Length.ToString("D2");
        }
示例#3
0
 /// <summary>Builds the spawn points</summary>
 protected void BuildSpawnPoints(SpawnResource spawn)
 {
     foreach (Joint joint in spawn.SpawnJoints)
     {
         joint.gameObject.GetComponent <MeshFilter>().sharedMesh       = PreviewMesh;
         joint.gameObject.GetComponent <MeshRenderer>().sharedMaterial = PreviewMat;
     }
 }
示例#4
0
        private void Handle_Garden_Patch_Destroyed()
        {
            SpawnResource plot = base.gameObject.GetComponent <SpawnResource>();

            SpawnResource.Id ID = plot ? plot.id : SpawnResource.Id.NONE;

            object return_value = new object();

            SiscosHooks.call(HOOK_ID.Destroyed_Garden_Patch, base.gameObject, ref return_value, new object[] { ID });
        }
示例#5
0
        /// <summary>Builds this Item</summary>
        protected override void Build()
        {
            // Load Material
            TreeMat   = CreateTreeMat();
            LeavesMat = CreateLeavesMat();

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Name;

            GameObject tree = Prefab.FindChild("tree_pogo");

            tree.transform.localScale = TreeScale;

            GameObject leaves = tree.FindChild("leaves_pogo");

            leaves.transform.localScale = LeavesScale;

            // Load Components
            SpawnResource spawn = Prefab.GetComponent <SpawnResource>();

            MeshFilter   tMesh   = tree.GetComponent <MeshFilter>();
            MeshRenderer tRender = tree.GetComponent <MeshRenderer>();
            MeshCollider tCol    = tree.GetComponent <MeshCollider>();

            MeshFilter   lMesh   = leaves.GetComponent <MeshFilter>();
            MeshRenderer lRender = leaves.GetComponent <MeshRenderer>();
            MeshCollider lCol    = tree.GetComponent <MeshCollider>();

            // Setup Components
            spawn.id                  = ID;
            spawn.ObjectsToSpawn      = GameContext.Instance.LookupDirector.GetPrefabs(ToSpawn);
            spawn.BonusObjectsToSpawn = BonusToSpawn != null?GameContext.Instance.LookupDirector.GetPrefabs(BonusToSpawn) : new GameObject[0];

            spawn.MaxObjectsSpawned         = MaxObjectsSpawned;
            spawn.MinObjectsSpawned         = MinObjectsSpawned;
            spawn.MinNutrientObjectsSpawned = MinNutrientObjectsSpawned == -1 ? MaxObjectsSpawned : MinNutrientObjectsSpawned;
            spawn.MinSpawnIntervalGameHours = MinSpawnIntervalGameHours;
            spawn.MaxSpawnIntervalGameHours = MaxSpawnIntervalGameHours;
            spawn.BonusChance        = BonusChance;
            spawn.minBonusSelections = MinBonusSelections;

            tMesh.sharedMesh       = TreeMesh ?? tMesh.sharedMesh;
            tRender.sharedMaterial = TreeMat ?? tRender.sharedMaterial;
            tCol.sharedMesh        = TreeMesh ?? tCol.sharedMesh;

            lMesh.sharedMesh       = LeavesMesh ?? lMesh.sharedMesh;
            lRender.sharedMaterial = LeavesMat ?? lRender.sharedMaterial;
            lCol.sharedMesh        = LeavesMesh ?? lCol.sharedMesh;

            // Builds the Spawn Points
            BuildSpawnPoints(spawn);
        }
示例#6
0
        public override void Setup(GameObject root)
        {
            // Setup for Main Object
            SpawnResource res = root.GetComponent <SpawnResource>();

            res.BonusChance = 0.01f;
            res.forceDestroyLeftoversOnSpawn = false;
            res.id = spawnable.ID;
            res.MaxActiveSpawns           = 0;
            res.MaxObjectsSpawned         = 20;
            res.MaxSpawnIntervalGameHours = 24;
            res.MaxTotalSpawns            = 0;
            res.minBonusSelections        = 0;
            res.MinNutrientObjectsSpawned = 20;
            res.MinObjectsSpawned         = 15;
            res.MinSpawnIntervalGameHours = 18;
            res.wateringDurationHours     = 23;
            res.ObjectsToSpawn            = spawnable.objectsToSpawn.ToArray();
            res.BonusObjectsToSpawn       = spawnable.bonusObjectsToSpawn.ToArray();

            foreach (GameObject obj in res.ObjectsToSpawn)
            {
                if (obj.GetComponent <ResourceCycle>().unripeGameHours == 0)
                {
                    obj.GetComponent <ResourceCycle>().unripeGameHours = 6;
                }
            }

            foreach (GameObject obj in res.BonusObjectsToSpawn)
            {
                if (obj.GetComponent <ResourceCycle>().unripeGameHours == 0)
                {
                    obj.GetComponent <ResourceCycle>().unripeGameHours = 6;
                }
            }

            BoxCollider box = root.GetComponent <BoxCollider>();

            box.size      = new Vector3(8f, 0.1f, 8f);
            box.center    = new Vector3(0, 0, 0.1f);
            box.isTrigger = true;

            root.GetComponent <ScaleYOnlyMarker>().doNotScaleAsReplacement = false;

            // Setup Joints
            res.SpawnJoints = root.GetComponentsInChildren <FixedJoint>();
        }
示例#7
0
        /// <summary>Registers the item into it's registry</summary>
        public override SpawnResourceItem Register()
        {
            Build();

            // Collect Joints
            SpawnResource spawn = Prefab.GetComponent <SpawnResource>();

            spawn.SpawnJoints = Prefab.GetComponentsInChildren <Joint>();

            LookupRegistry.RegisterSpawnResource(Prefab);

            if (IsGarden)
            {
                RegisterSlot();
            }

            return(this);
        }
        static void Prefix(ref SpawnResourceModel.Participant part)
        {
            if (SRRandomizer.produce_randomMode == RandomMode.DISABLED)
            {
                return;
            }

            if (!(part is SpawnResource))
            {
                return;
            }

            SpawnResource sr = (SpawnResource)part;

            for (int i = 0; i < sr.ObjectsToSpawn.Length; i++)
            {
                sr.ObjectsToSpawn[i] = SRRandomizer.GetRandomizedProduce(sr.ObjectsToSpawn[i]);
            }
        }
        protected override void Build()
        {
            // Pre Build Manipulation

            // Build Control
            base.Build();

            // Post Build Manipulation
            SpawnResource spawn = Prefab.GetComponent <SpawnResource>();

            GameObject fixedVeggie = GardenResourceFixes.GetFixedPrefab(Identifiable.Id.GINGER_VEGGIE, (obj) => obj.GetComponent <ResourceCycle>().unripeGameHours = 12);

            spawn.BonusObjectsToSpawn = new[] { fixedVeggie };

            // Fix Sprouts
            foreach (GameObject sprout in Prefab.FindChildren("Sprout"))
            {
                sprout.GetComponent <MeshFilter>().sharedMesh       = SRObjects.Get <Mesh>("sprout_parsnip");
                sprout.GetComponent <MeshRenderer>().sharedMaterial = SRObjects.Get <Material>("parsnip NoSway");
            }
        }
示例#10
0
    void Start()
    {
        // should be pairs
        Debug.Assert(buttonGOs.Length == placeables.Length);

        // get spawn resources
        spawnResource = GetComponent <SpawnResource>();

        // transfer to needed components
        buttons = new Button[buttonGOs.Length];
        for (int i = 0; i < buttonGOs.Length; i++)
        {
            buttons[i] = buttonGOs[i].GetComponent <Button>();
        }

        // write cost on buttons
        for (int i = 0; i < buttonGOs.Length; i++)
        {
            float cost = placeables[i].placingCost;
            buttonGOs[i].GetComponentInChildren <Text>().text += string.Format(" ({0}$)", (int)cost);
        }
    }
示例#11
0
    // Start is called before the first frame update
    void Start()
    {
        Vector3 centerVector = new Vector3(.5f, 0, .5f);
        int     startPos     = (mapSize / 2) * -1;

        for (int x = startPos; x < mapSize / 2; x++)
        {
            for (int z = startPos; z < mapSize / 2; z++)
            {
                GameObject instantiated = Instantiate(terrainTile, centerVector + new Vector3(x, 0, z), transform.rotation) as GameObject;
                instantiated.transform.SetParent(gameObject.transform);

                SpawnResource script = instantiated.AddComponent <SpawnResource>();
                script.spawnRatePercentage = spawnRatePercentage;
                script.possibleSpawns      = possibleSpawns;
            }
        }

        foreach (var renderer in gameObject.GetComponentsInChildren <Renderer>())
        {
            // Creates a nice grassy color
            renderer.material.color = new Color(0, (Random.value / 8) + .4f, 0);
        }
    }
示例#12
0
    void Start()
    {
        laserBeam.gameObject.SetActive(false);
        lookAtMouseScript = masterEye.GetComponent <LookAtMouse>();
        oldMousePosition  = Input.mousePosition;
        platform          = GameObject.FindWithTag("Platform").GetComponent <Platform>();

        // get default glow color of blocks from any block
        defaultBlockMaterial = level.world[0, 0].GetComponentInChildren <Renderer>().sharedMaterial;
        // create lifted material (so it can be shared by all lifted blocks)
        liftedBlockMaterial = new Material(defaultBlockMaterial);
        liftedBlockMaterial.SetColor("_MKGlowColor", liftedBlockColor);


        // get spawn resource
        spawnResource = GetComponent <SpawnResource>();
        spawnResource.onChange.AddListener(() => spawnResourceText.text = spawnResource.currentValue + " $");

        // get material of master rail
        defaultRailMaterial = level.rail[0].GetChild(1).GetComponent <Renderer>().material;

        // stop blinking of lifted blocks
        for (int i = 0; i < level.world.GetLength(0); i++)
        {
            for (int u = 0; u < level.world.GetLength(1); u++)
            {
                var block = level.world[i, u].transform;
                if (block.position.y > blockMinYValue && block.tag.Equals("RoomBlock"))
                {
                    SetBlockMaterial(block, liftedBlockMaterial);
                }
            }
        }

        // unlocked units and obstacles
        #region
        if (GameData.Instance.suicideRobotUnlocked && !suicideRobot.activeSelf)
        {
            suicideRobot.SetActive(true);
        }
        if (GameData.Instance.sniperUnlocked && !sniper.activeSelf)
        {
            sniper.SetActive(true);
        }
        if (GameData.Instance.turretUnlocked && !turret.activeSelf)
        {
            turret.SetActive(true);
        }
        if (GameData.Instance.hackingAreaUnlocked && !hackingArea.activeSelf)
        {
            hackingArea.SetActive(true);
        }
        if (GameData.Instance.firewallUnlocked && !firewall.activeSelf)
        {
            firewall.SetActive(true);
        }
        if (GameData.Instance.fragmentationSawUnlocked && !fragmentation_Saw.activeSelf)
        {
            fragmentation_Saw.SetActive(true);
        }
        #endregion

        // start no spawn zone
        StartCoroutine(AutoUpdateNoSpawnZone());
    }