void Start()
 {
     hm = GameObject.Find("HazardMGR").GetComponent <HazardManager>();
 }
 // Start is called before the first frame update
 void Start()
 {
     hazardManager = GetComponent <HazardManager>();
     StartCoroutine(hazardWaves());
 }
Beispiel #3
0
 void Awake()
 {
     hm      = GameObject.Find("HazardMGR").GetComponent <HazardManager>();
     dogANIM = gameObject.GetComponent <Animator>();
     dogANIM.SetInteger("dogNum", Random.Range(1, 10));
 }
Beispiel #4
0
 // Start is called before the first frame update
 void Start()
 {
     hazardManager = FindObjectOfType <HazardManager>();
 }
    //! Called by unity engine on start up to initialize variables.
    public void Start()
    {
        // Get a reference to the player.
        player = GameObject.Find("Player").GetComponent <PlayerController>();

        // Get a reference to the rocket.
        rocketScript = rocketObject.GetComponent <Rocket>();

        // Initiate meteor shower location list.
        meteorShowerLocationList = new List <Vector3>();

        // Create the hazard manager.
        hazardManager = new HazardManager(this);

        // Create the combined mesh manager.
        meshManager = new CombinedMeshManager(this);

        // Create an object list to hold the player's most recently built objects for the 'undo' function.
        undoBlocks = new List <Block>();

        // Create mod block name list.
        modBlockNames   = new List <string>();
        modBlockHolders = new List <GameObject[]>();

        // Load chunk size setting.
        int cs = PlayerPrefs.GetInt("chunkSize");

        chunkSize = cs > 0 ? cs : 40;

        // Load chunk size setting.
        float simSpeed = PlayerPrefs.GetFloat("simulationSpeed");

        simulationSpeed = simSpeed > 0 ? simSpeed : 0.02f;

        // Create initial iron block holder for mesh manager.
        GameObject ironInit = Instantiate(ironHolder, transform.position, transform.rotation);

        ironInit.transform.parent = builtObjects.transform;
        ironInit.GetComponent <MeshPainter>().ID = 0;
        ironInit.SetActive(false);
        ironHolders = new GameObject[] { ironInit };

        // Create initial iron block holder for mesh manager.
        GameObject glassInit = Instantiate(glassHolder, transform.position, transform.rotation);

        glassInit.transform.parent = builtObjects.transform;
        glassInit.GetComponent <MeshPainter>().ID = 0;
        glassInit.SetActive(false);
        glassHolders = new GameObject[] { glassInit };

        // Create initial iron block holder for mesh manager.
        GameObject steelInit = Instantiate(steelHolder, transform.position, transform.rotation);

        steelInit.transform.parent = builtObjects.transform;
        steelInit.GetComponent <MeshPainter>().ID = 0;
        steelInit.SetActive(false);
        steelHolders = new GameObject[] { steelInit };

        // Create initial iron block holder for mesh manager.
        GameObject brickInit = Instantiate(brickHolder, transform.position, transform.rotation);

        brickInit.transform.parent = builtObjects.transform;
        brickInit.GetComponent <MeshPainter>().ID = 0;
        brickInit.SetActive(false);
        brickHolders = new GameObject[] { brickInit };
    }
Beispiel #6
0
        public async void AddPoints(ChatMessage message)
        {
            DateTime now = DateTime.Now;

            using var context = ContextFactory.GetContext();

            Player player = context.GetPlayer(Client, message);

            TimeSpan timeSinceLastPointGain = now - player.LastPointsGained;

            Int32 playerStorage = player.GetTotalStorage();

            if (timeSinceLastPointGain >= PointGainCooldown)
            {
                if (player.Points >= playerStorage)
                {
                    Client.SpoolMessageAsMe(message.Channel, player, $" You have {player.Points}/{playerStorage} cheese and cannot store any more. Consider buying more cheese storage with \"!cheese buy storage\".");
                    return;
                }

                RecipeInfo initialCheese = Random.NextElement(RecipeRepository, player.CheeseUnlocked);

                RecipeModifier modifier = Random.NextElement(RecipeModifierManager, (Int32)player.NextCheeseModifierUpgradeUnlock);

                RecipeInfo cheese = modifier.Modify(initialCheese);

                StringBuilder outputMessage = new();

                String infestationStatus = HazardManager.UpdateInfestationStatus(player);

                var infestationTask = context.SaveChangesAsync();

                if (!String.IsNullOrWhiteSpace(infestationStatus))
                {
                    outputMessage
                    .Append(infestationStatus)
                    .Append(Random.NextElement(EmoteManager.Get(message.Channel, EmoteCategory.Rat)))
                    .Append(' ');
                }

                Boolean isCritical = Random.TryPercentChance((Int32)player.NextCriticalCheeseUpgradeUnlock * RankUpgradeExtensions.CriticalCheeseUpgradePercent);

                await infestationTask;

                var modifiedPoints = player.GetModifiedPoints(cheese.Points, isCritical);

                player.AddPoints(modifiedPoints);

                player.LastPointsGained = now;

                var addPointsTask = context.SaveChangesAsync();

                Boolean isPositive = cheese.Points > 0;

                var emoteCategory = isPositive ? EmoteCategory.Positive : EmoteCategory.Negative;

                var emoteList = EmoteManager.Get(message.Channel, emoteCategory);

                if (isCritical)
                {
                    outputMessage.Append(Random.NextElement(emoteList));

                    if (!isPositive)
                    {
                        outputMessage.Append(" NEGATIVE ");
                    }

                    outputMessage
                    .Append(" CRITICAL CHEESE!!! ")
                    .Append(Random.NextElement(emoteList))
                    .Append(' ');
                }

                outputMessage.Append($"You made some {cheese.Name}. {Random.NextElement(emoteList)} ({(isPositive ? "+" : String.Empty)}{modifiedPoints} cheese)");

                Client.SpoolMessageAsMe(message.Channel, player, outputMessage.ToString());

                await addPointsTask;
                return;
            }

            TimeSpan timeUntilNextValidPointGain = PointGainCooldown - timeSinceLastPointGain;

            String timeToWait = timeUntilNextValidPointGain.Format();

            Client.SpoolMessageAsMe(message.Channel, player,
                                    $"You must wait {timeToWait} until you can make more cheese. {Random.NextElement(EmoteManager.Get(message.Channel, EmoteCategory.Waiting))}",
                                    Priority.Low);
        }