コード例 #1
0
 public void Cycle()
 {
     //speed manevuer weight morale luck charisma
     //speed, maneuver - no dmg from deep ocean
     //morale - bonus hp
     //luck - bonus gold
     //charisma - bonus item
     //inventory.LootItem(Random.Range(1+ (currentLevel - 1) * 12,13+(currentLevel-1)*12));
     //weight - chance to lose item
     if (stats_combined != null)
     {
         if (stats_combined.Charisma * 0.001 > Random.Range(0f, 1f))
         {
             if (player.GetComponent <PlayerBehav>().location.GetComponent <Isle_Behaviour>().field.evaluate() == 1)
             {
                 GameObject spawned = Instantiate(animated_info);
                 spawned.transform.SetParent(GameObject.Find("Player").transform);
                 status_update_image        = spawned.transform.GetChild(0).GetComponentInChildren <SpriteRenderer>();
                 status_update_text         = spawned.GetComponentInChildren <TextMeshPro>();
                 status_update_text.text    = "+ 1";
                 status_update_text.color   = Color.green;
                 status_update_image.sprite = Resources.Load <Sprite>("Sprites/Icons/barrel");
                 inventory.LootItem(Random.Range(1 + (currentLevel - 1) * 12, 13 + (currentLevel - 1) * 12));
             }
             Debug.Log("Prkd Charisma");
         }
         if (stats_combined.Speed * 0.001 > Random.Range(0f, 1f) || stats_combined.Maneuver * 0.01 > Random.Range(0f, 1f))
         {
             if (player.GetComponent <PlayerBehav>().location.GetComponent <Isle_Behaviour>().field.evaluate() == 1 && shipHealth > 0)
             {
                 GameObject spawned = Instantiate(animated_info);
                 spawned.transform.SetParent(GameObject.Find("Player").transform);
                 status_update_image        = spawned.transform.GetChild(0).GetComponentInChildren <SpriteRenderer>();
                 status_update_text         = spawned.GetComponentInChildren <TextMeshPro>();
                 status_update_text.text    = "+ 2";
                 status_update_text.color   = Color.green;
                 status_update_image.sprite = Resources.Load <Sprite>("Sprites/Icons/health");
                 AddShipHealth(2);
             }
             Debug.Log("Prkd  Speed/Maneuver");
         }
         if (stats_combined.Morale * 0.001 > Random.Range(0f, 1f) && shipHealth > 0)
         {
             if (player.GetComponent <PlayerBehav>().location.GetComponent <Isle_Behaviour>().field.evaluate() == 1)
             {
                 GameObject spawned = Instantiate(animated_info);
                 spawned.transform.SetParent(GameObject.Find("Player").transform);
                 status_update_image = spawned.transform.GetChild(0).GetComponentInChildren <SpriteRenderer>();
                 status_update_text  = spawned.GetComponentInChildren <TextMeshPro>();
                 int number = Random.Range(1, 10);
                 status_update_text.text    = "+ " + number;
                 status_update_text.color   = Color.green;
                 status_update_image.sprite = Resources.Load <Sprite>("Sprites/Icons/health");
                 AddShipHealth(number);
             }
             Debug.Log("Prkd  Morale");
         }
         if (stats_combined.Luck * 0.001 > Random.Range(0f, 1f))
         {
             if (player.GetComponent <PlayerBehav>().location.GetComponent <Isle_Behaviour>().field.evaluate() == 1)
             {
                 GameObject spawned = Instantiate(animated_info);
                 spawned.transform.SetParent(GameObject.Find("Player").transform);
                 status_update_image = spawned.transform.GetChild(0).GetComponentInChildren <SpriteRenderer>();
                 status_update_text  = spawned.GetComponentInChildren <TextMeshPro>();
                 int number = Random.Range(1, 4);
                 status_update_text.text    = "+ " + number;
                 status_update_text.color   = Color.green;
                 status_update_image.sprite = Resources.Load <Sprite>("Sprites/Icons/coins");
                 AddGold(number);
             }
             Debug.Log("Prkd  Luck");
         }
         if (stats_combined.Weight * 0.001 > Random.Range(0f, 1f))
         {
             if (player.GetComponent <PlayerBehav>().location.GetComponent <Isle_Behaviour>().field.evaluate() == 1)
             {
                 GameObject spawned = Instantiate(animated_info);
                 spawned.transform.SetParent(GameObject.Find("Player").transform);
                 status_update_image        = spawned.transform.GetChild(0).GetComponentInChildren <SpriteRenderer>();
                 status_update_text         = spawned.GetComponentInChildren <TextMeshPro>();
                 status_update_text.text    = "- 1";
                 status_update_text.color   = Color.red;
                 status_update_image.sprite = Resources.Load <Sprite>("Sprites/Icons/barrel");
                 inventory.DropRandom();
             }
             Debug.Log("Prkd  Weight");
         }
     }
     map_generator.Cycle();
     compass.Cycle();
 }