示例#1
0
 public Fog(Region region, FogKind fogKind) : base(region)
 {
     revealed     = false;
     this.fogKind = fogKind;
     hiddenObject = null;
 }
示例#2
0
 public void setFogKind(FogKind fk)
 {
     this.fogKind = fk;
 }
示例#3
0
        public bool activate(Hero hero)
        {
            //need to reveal first;
            if (this.revealed != true)
            {
                reveal();
            }
            string description = "";

            if (this.fogKind != FogKind.None)
            {
                if (this.fogKind == FogKind.TwoWP)
                {
                    hero.setWillpowerPoints(hero.getWillpowerPoints() + 2);
                }
                if (this.fogKind == FogKind.Witch)
                {
                    int roll = Random.Range(1, 7);
                    Debug.Log(roll);
                    int    rank = -1;
                    Region r    = null;
                    if (roll == 1 || roll == 2)
                    {
                        r    = GameObject.Find("R (37)").GetComponent <Node>().GetRegion();
                        rank = 37;
                        Vector3 position = new Vector3(-3.72f, 0.0f, -4.35f);
                        GameObject.Find("GameManager").GetComponent <GameManager>().updateHerb(true, position);
                    }
                    if (roll == 3 || roll == 4)
                    {
                        r    = GameObject.Find("R (67)").GetComponent <Node>().GetRegion();
                        rank = 67;
                        Vector3 position = new Vector3(5.17f, 0.0f, -2.02f);
                        GameObject.Find("GameManager").GetComponent <GameManager>().updateHerb(true, position);
                    }
                    if (roll == 5 || roll == 6)
                    {
                        r    = GameObject.Find("R (61)").GetComponent <Node>().GetRegion();
                        rank = 61;
                        Vector3 position = new Vector3(6.24f, 0.0f, 1.18f);
                        GameObject.Find("GameManager").GetComponent <GameManager>().updateHerb(true, position);
                    }
                    r.setHerb(true);
                    string     show    = revealedFogDescription();
                    string     show2   = show + "\n\nHerb is on space " + rank;
                    GameObject FogInfo = GameObject.Find("FogInfo").transform.GetChild(0).gameObject;
                    GameObject DUI     = null;
                    for (int i = 0; i < FogInfo.transform.childCount - 1; i++)
                    {
                        if (FogInfo.transform.GetChild(i).transform.name == "Description")
                        {
                            DUI = FogInfo.transform.GetChild(i).gameObject;
                        }
                    }
                    DUI.GetComponent <Text>().text = show2;
                    FogInfo.SetActive(true);
                    GameObject.Find("GameManager").GetComponent <GameManager>().witchFound = true;
                }
                if (this.fogKind == FogKind.ThreeWP)
                {
                    hero.setWillpowerPoints(hero.getWillpowerPoints() + 3);
                }
                if (this.fogKind == FogKind.SP)
                {
                    hero.setStrengthPoints(hero.getStrengthPoints() + 1);
                }
                if (this.fogKind == FogKind.Gold)
                {
                    hero.setGold(hero.getGold() + 1);
                }
                if (this.fogKind == FogKind.Wineskin)
                {
                    Wineskin wineskin = (Wineskin)this.hiddenObject;
                    hero.addItem(wineskin);
                    Debug.Log("wineskin added");
                }
                if (this.fogKind == FogKind.Event)
                {
                    ((Event)getHiddenObject()).applyEventEffect();
                }
                if (this.fogKind != FogKind.Event && this.fogKind != FogKind.Witch)
                {
                    // method below return  a string of the description
                    // event has its own description, so first check whether what hidden is event or not
                    description = revealedFogDescription();
                    GameObject FogInfo = GameObject.Find("FogInfo").transform.GetChild(0).gameObject;
                    GameObject DUI     = null;
                    for (int i = 0; i < FogInfo.transform.childCount; i++)
                    {
                        if (FogInfo.transform.GetChild(i).transform.name == "Description")
                        {
                            DUI = FogInfo.transform.GetChild(i).gameObject;
                        }
                    }
                    DUI.GetComponent <Text>().text = description;
                    FogInfo.SetActive(true);
                }
                // after the fog effect, set fogkind to None
                this.fogKind = FogKind.None;
                GameObject.Find("GameManager").GetComponent <GameManager>().updateFog();
                return(true);
            }
            return(false);                      // the fog has already been activated
        }