Inheritance: MonoBehaviour
Example #1
0
 public Trait AddTo(ClickScript cs)
 {
     var trait = Instantiate();
     trait.Attach(cs);
     cs.status.Add(trait);
     return trait;
 }
Example #2
0
	void OnRoll(ClickScript cs, RollData data)
	{
		var nume = data.type.GetEnumerator ();
		while (nume.MoveNext()) 
		{
			if (nume.Current.CompareTo("trap")==0 || nume.Current.CompareTo("ambush")==0)
				data.bonus.Add(new KeyValuePair<List<string>, int>(new List<string>(), 4));
		}
	}
Example #3
0
 void OnTurnEnd(ClickScript cs, TurnData data)
 {
     if (data.type == TurnType.dungeon)
     {
         if (cs.hp.current < 3)
         {
             cs.hp.current += 1;
             cs.OnHealthChanged(1);
         }
     }
 }
Example #4
0
    public RollData(RollData other)
    {
        source = other.source;
        target = other.target;

        type = new List<string>(other.type);

        bonus = new List<KeyValuePair<List<string>, int>>();

        roll = new List<int>();

        this.other = other;
        other.other = this;
    }
Example #5
0
	void OnRoll(ClickScript cs, RollData data)
	{
		for (int i=0;i<data.bonus.Count;++i)
		{
			var nume = data.bonus[i].Key.GetEnumerator();
			bool is_darkness_penalty = false;
			while (nume.MoveNext())
			{
				if (nume.Current.CompareTo("darkness") == 0)
					is_darkness_penalty = true;
			}
			if (is_darkness_penalty)
				data.bonus[i] = new KeyValuePair<List<string>, int>(data.bonus[i].Key, data.bonus[i].Value + 4);
		}
	}
Example #6
0
 void OnRecalculateStats(ClickScript cs, CharacterData data)
 {
     data.name = "Murk";
     if (cs.hp.current > 0)
     {
         data.STR = STR;
         data.DEX = DEX;
         data.CON = CON;
         data.INT = INT;
         data.WIS = WIS;
         data.CHA = CHA;
     }
     else
     {
         data.name += " Corpse";
     }
 }
Example #7
0
	void Update()
    {
        if (tm.current_turnholder != null)
            if (tm.current_turnholder.player)
                last_turnholder = tm.current_turnholder;
        if (cs != null)
        {
            nameText.text = cs.stats.name;

            if (cs.team == last_turnholder.team)
            {
                healthFillImage.color = new Color(0.0f, 1.0f, 0.0f, 1.0f);
                healthFill.anchorMax = new Vector2(Mathf.Max(0.0f, ((float)cs.hp.current) / ((float)cs.hp.max)), 1.0f);

                healthText.text = cs.hp.current + " / " + cs.hp.max;

                statTexts[0].text = "STR: " + cs.stats.STR;
                statTexts[1].text = "DEX: " + cs.stats.DEX;
                statTexts[2].text = "CON: " + cs.stats.CON;
                statTexts[3].text = "INT: " + cs.stats.INT;
                statTexts[4].text = "WIS: " + cs.stats.WIS;
                statTexts[5].text = "CHA: " + cs.stats.CHA;
            }
            else
            {
                healthFillImage.color = new Color(1.0f, 0.0f, 0.0f, 1.0f);
                healthFill.anchorMax = new Vector2(cs.hp.current > 0 ? 1.0f : 0.0f, 1.0f);

                healthText.text = (cs.hp.current - cs.hp.max).ToString();

                statTexts[0].text = "STR: ?";
                statTexts[1].text = "DEX: ?";
                statTexts[2].text = "CON: ?";
                statTexts[3].text = "INT: ?";
                statTexts[4].text = "WIS: ?";
                statTexts[5].text = "CHA: ?";
            }
        }
        else
        {
            gameObject.SetActive(false);
        }
	}
Example #8
0
	void OnRoll(ClickScript cs, RollData data)
	{
		bool ispray = false;
		bool isholy = false;
		var nume = data.type.GetEnumerator ();
		while (nume.MoveNext()) 
		{
			if (nume.Current.CompareTo("pray")==0)
				ispray = true;
		}
		nume = data.type.GetEnumerator ();
		while (nume.MoveNext()) 
		{
			if (nume.Current.CompareTo("holy")==0)
				isholy = true;
		}
		if (ispray && isholy) 
			data.bonus.Add (new KeyValuePair<List<string>, int> (new List<string> (), 2));
	}
Example #9
0
	void OnRoll(ClickScript cs, RollData data)
	{
		bool use = false;
		bool iseldritch = false;
		var nume = data.type.GetEnumerator ();
		while (nume.MoveNext()) 
		{
			if (nume.Current.CompareTo("use")==0)
				use = true;
		}
		nume = data.type.GetEnumerator ();
		while (nume.MoveNext()) 
		{
			if (nume.Current.CompareTo("eldritch")==0)
				iseldritch = true;
		}
		if (use && iseldritch) 
			data.bonus.Add (new KeyValuePair<List<string>, int> (new List<string> (), 4));
	}
Example #10
0
	void OnRoll(ClickScript cs, RollData data)
	{
		bool use = false;
		bool identify = false;
		bool iseldritch = false;
		var nume = data.type.GetEnumerator ();
		while (nume.MoveNext()) 
		{
			if (nume.Current.CompareTo("use")==0)
				use = true;
		}
		nume = data.type.GetEnumerator ();
		while (nume.MoveNext()) 
		{
			if (nume.Current.CompareTo("eldritch")==0)
				iseldritch = true;
		}
		nume = data.type.GetEnumerator ();
		while (nume.MoveNext()) 
		{
			if (nume.Current.CompareTo("identify")==0)
				identify = true;
		}
		if (use && iseldritch || identify)
		{
            if (data.roll.Count > 0)
            {
                int smallest_id = 0;
                for (int i = 1; i < data.roll.Count; ++i)
                {
                    if (data.roll[i] < data.roll[smallest_id])
                        smallest_id = i;
                }
                data.roll[smallest_id] = Math.Max(data.roll[smallest_id], RandomManager.d6());
            }
		}
	}
Example #11
0
	void OnHealthChanged(ClickScript cs, int difference)
	{
		if (difference < 0)
			bonus -= 4;
	}
Example #12
0
	public override void Attach(ClickScript cs)
	{

	}
Example #13
0
 public virtual void Detach(ClickScript cs) { }
Example #14
0
 public abstract void Activate(Vector3 position, ClickScript cs);
Example #15
0
    public void Erase(ClickScript cs)
    {
        if (current_turnholder == cs)
            current_turnholder = null;

        var nume = order.GetEnumerator();
        while (nume.MoveNext())
            nume.Current.Value.Remove(cs);

        var nume2 = new_order.GetEnumerator();
        while (nume2.MoveNext())
            nume2.Current.Value.Remove(cs);

        on_hold.Remove(cs);

        Destroy(cs.gameObject);
    }
Example #16
0
	// Update is called once per frame
	void Update () {
        if (current_turnholder == null)
        {
            var teams = GetTeamCount();
            if (!teams.ContainsKey(0))
                gm.defeat.SetActive(true);
            if (!teams.ContainsKey(1))
                gm.victory.SetActive(true);

            var nume = order.GetEnumerator();
            while (nume.MoveNext())
            {
                var nume2 = nume.Current.Value.GetEnumerator();
                while (nume2.MoveNext())
                {
                    if (nume2.Current.Hold())
                    {
                        on_hold.Add(nume2.Current);
                    }
                    else
                    {
                        current_turnholder = nume2.Current;
                        float time_to_advance = nume.Current.Key;
                        while (nume2.MoveNext())
                        {
                            if (!new_order.ContainsKey(0.0f))
                                new_order.Add(0.0f, new List<ClickScript>());
                            new_order[0.0f].Add(nume2.Current);
                        }
                        while (nume.MoveNext())
                            new_order.Add(nume.Current.Key - time_to_advance, nume.Current.Value);
                        current_turnholder.my_turn = true;
                        current_turnholder.advance = 0.0f;
                    }
                }
            }
        }
        if (current_turnholder != null)
        {
            cam.target = current_turnholder;
            while (current_turnholder.advance>0.0f)
            {
                TurnData data = new TurnData();
                data.time = current_turnholder.advance;
                data.type = TurnType.battle;
                current_turnholder.OnTurnEnd(data);
                if (current_turnholder.advance>0.0f)
                {
                    current_turnholder.my_turn = false;
                    if (!new_order.ContainsKey(current_turnholder.advance))
                        new_order.Add(current_turnholder.advance, new List<ClickScript>());
                    new_order[current_turnholder.advance].Add(current_turnholder);
                    order = new_order;
                    new_order = new Dictionary<float, List<ClickScript>>();
                    current_turnholder = null;
                    break;
                }
            }
        }
	}
Example #17
0
 public override void Detach(ClickScript cs)
 {
     cs.onRoll[100.0f] -= OnRoll;
     cs.onTurnEnd[0.0f] -= OnTurnEnd;
 }
Example #18
0
 public abstract ActionData GetData(Vector3 position, ClickScript cs);
Example #19
0
 public override ActionData GetData(Vector3 position, ClickScript cs)
 {
     throw new NotImplementedException();
 }
Example #20
0
 public override void Activate(Vector3 position, ClickScript cs)
 {
     throw new NotImplementedException();
 }
Example #21
0
 public HitData(ClickScript source, ClickScript target)
 {
     this.source = source;
     this.target = target;
     damage = new List<KeyValuePair<List<string>, int>>();
 }
Example #22
0
	void OnTurnEnd(ClickScript cs, TurnData data)
	{
		if (data.type == TurnType.battle)
			bonus = 0;
	}
Example #23
0
	// Update is called once per frame
	void Update () {
        Vector3 prev_pos = transform.position;
        
        if (tm.current_turnholder != null)
            if (tm.current_turnholder.player)
                last_turnholder = tm.current_turnholder;

        uid.cs = null;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        var rh = Physics.RaycastAll(ray);
        rend.enabled = false;
        if (!UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
        {
            rend.material.color = new Color(1.0f, 1.0f, 1.0f);
            int rh_final = -1;
            for (int i = 0; i < rh.Length; ++i)
            {
                ClickScript other = rh[i].transform.GetComponentInParent<ClickScript>();
                if (other != null)
                {
                    rh_final = i;
                }
                else
                {
                    if (rh_final < 0)
                        rh_final = i;
                }
            }
            if (rh_final >= 0)
            {
                ClickScript other = rh[rh_final].transform.GetComponentInParent<ClickScript>();
                uid.cs = other;
                if (other != null)
                    uid.gameObject.SetActive(true);
                if (other != null)
                {
                    rend.material.color = new Color(1.0f, 0.0f, 0.0f);
                    if (last_turnholder != null)
					    if (other.team == last_turnholder.team)
						    rend.material.color = new Color(0.0f, 1.0f, 0.0f);
                    transform.position = other.transform.position;
                    transform.localScale = rh[rh_final].transform.localScale;
                }
                else
                {
                    Vector2 target = rh[rh_final].point;
                    target.x = Mathf.Round(target.x - 0.5f) + 0.5f;
                    target.y = Mathf.Round(target.y - 0.5f) + 0.5f;

                    transform.position = target;
                }
                rend.enabled = true;
            }
        }

        bool ce = !rend.enabled || tm.current_turnholder == null;
        if (tm.current_turnholder != null)
            ce |= !tm.current_turnholder.my_turn;
        if (pm != null && tm != null)
        {
            if (ce)
                pm.Clear();
            else
            {
                if (prev_pos != transform.position || rend.enabled && !pe)
                {
                    TargetData td = new TargetData();
                    td.start = new Vector2(tm.current_turnholder.transform.position.x, tm.current_turnholder.transform.position.y);
                    td.end = new Vector2(transform.position.x, transform.position.y);
                    td.searcher = tm.current_turnholder;
                    td.use_end = true;

                    tm.terrain.GetPath(td);

                    if (td.paths.Count > 0)
                        pm.Construct(td.paths[0], transform.position);
                    else
                        pm.Clear();
                }
            }
        }

        pe = ce;
    }
Example #24
0
	void OnRoll(ClickScript cs, RollData data)
	{
		data.bonus.Add (new KeyValuePair<List<string>, int> (new List<string> (), bonus));
	}
Example #25
0
 public override void Detach(ClickScript cs)
 {
     cs.onRecalculateStats[-100.0f] -= OnRecalculateStats;
 }
Example #26
0
	public override void Attach(ClickScript cs)
	{
		cs.onTurnEnd[0.0f] += OnTurnEnd;
		cs.onRoll[100.0f] += OnRoll;
		cs.onHealthChanged [0.0f] += OnHealthChanged;
	}
Example #27
0
	public override void Detach(ClickScript cs)
	{
		cs.onRoll[100.0f] -= OnRoll;
	}
Example #28
0
 void OnHealthChanged(ClickScript cs, int difference)
 {
     if (difference < 0)
         cs.hp.Damage(-1);
 }
Example #29
0
	public override void Attach(ClickScript cs)
	{
		cs.onRoll[100.0f] += OnRoll;
	}
Example #30
0
 public override void Attach(ClickScript cs)
 {
     cs.onHealthChanged[-100.0f] += OnHealthChanged;
 }