public void load(BoardState bs)
    {
        HexGenerator hxg = GameObject.FindObjectOfType <HexGenerator>();

        hxg.Clear();
        hxg.load(bs);

        foreach (Pawn go in GameObject.FindObjectsOfType <Pawn>())
        {
            go.tile = null;
            Destroy(go.gameObject);
        }

        InitiativeTracker it = GameObject.FindObjectOfType <InitiativeTracker>();

        it.pwn.Clear();
        List <Pawn> range = new List <Pawn>();

        foreach (PawnState go in bs.pawns)
        {
            Pawn po = GameObject.Instantiate(pawn).GetComponent <Pawn>();
            po.load(go);
            range.Add(po);
        }

        it.Start(bs.initiative, range);
    }
    public void transit(Transition t)
    {
        HexGenerator hxg = GameObject.FindObjectOfType <HexGenerator>();

        Pawn.selected.activate();
        last = t;
        hxg.get(t.x, t.y, t.z).OnMouseDown();
    }
Ejemplo n.º 3
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        if (GUILayout.Button("Generate hex"))
        {
            HexGenerator maze = (HexGenerator)target;
            maze.Generate();
        }

        if (GUILayout.Button("Get Path"))
        {
            HexGenerator maze = (HexGenerator)target;
            //maze.GetPath();
        }
    }
Ejemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        HexGenerator grid = GameObject.FindObjectOfType <HexGenerator>();

        tile               = grid.get(x, y, z);
        tile.occupier      = this;
        transform.position = tile.transform.position;
        x  = tile.x;
        y  = tile.y;
        z  = tile.z;
        id = UnityEngine.Random.Range(int.MinValue, int.MaxValue);
        if (color)
        {
            GetComponentInChildren <BodyGenerator>().transform.localScale *= new Vector2(-1, 1);
        }

        name += "" + initiative;
    }
Ejemplo n.º 5
0
    public void activate()
    {
        //selected = this;
        if (!tile)
        {
            Start();
        }
        HexGenerator grid = GameObject.FindObjectOfType <HexGenerator>();

        grid.all((tt => tt.overlay.sprite = null));

        foreach (HexTile tt in tile.neighbors)
        {
            if (tt.type == 0)
            {
                tt.Select();
            }
        }
    }
Ejemplo n.º 6
0
    public void OnMouseDown()
    {
        HexGenerator grid = GameObject.FindObjectOfType <HexGenerator>();

        if (overlay.sprite)
        {
            if (overlay.sprite == selected)
            {
                Pawn.selected.tile.occupier = null;
                Pawn.selected.tile          = this;

                /*Pawn.selected.x = x;
                *  Pawn.selected.y = y;
                *  Pawn.selected.z = z;*/
                occupier      = Pawn.selected;
                Pawn.selected = null;
            }
            else if (overlay.sprite == attack)
            {
                GameObject.FindObjectOfType <InitiativeTracker>().remove(occupier);
                Animator Anim1 = occupier.GetComponentInChildren <Animator>();
                Anim1.transform.parent = null;
                Anim1.Play("Die");

                Destroy(occupier.gameObject);
                Pawn.selected.tile.occupier = null;
                Pawn.selected.tile          = this;

                /*Pawn.selected.x = x;
                *  Pawn.selected.y = y;
                *  Pawn.selected.z = z;*/
                occupier = Pawn.selected;
                Debug.Log("HAAA");
                Debug.Log(occupier);
                Animator Anim2 = occupier.GetComponentInChildren <Animator>();

                switch (occupier.GetComponentInChildren <BodyGenerator>().weapons.GetLabel())
                {
                case "Bow": Anim2.Play("Attack Bow"); Debug.Log("ssAA"); break;

                case "Falchion": Anim2.Play("Attack Smasher"); Debug.Log("wwA"); break;

                case "Shield": Anim2.Play("Attack Blocker"); Debug.Log("aaaAA"); break;

                case "Spear": Anim2.Play("Attack Lancer"); Debug.Log("HsssAA"); break;

                default: Anim2.Play("Attack Brawler"); Debug.Log("fffA"); break;
                }
                occupier.attacking = true;
                Debug.Log(Anim2.GetCurrentAnimatorStateInfo(0).IsName("Idle"));

                Pawn.selected = null;
            }

            grid.all((t => t.overlay.sprite = null));
        }
        else
        {
            throw new NullReferenceException("" + x + "," + y + "," + z);
        }



        //overlay.sprite = selected;

        /*foreach(HexTile t in neighbors)
         * {
         *  t.overlay.sprite = selected;
         * }
         * /**/
        /*for(int i = 2; i <= 4; i++)
         * {
         *  if(grid.get(x, y + i, z - i))
         *      grid.get(x, y + i, z - i).overlay.sprite = selected;
         *  if (grid.get(x + i, y - i, z))
         *      grid.get(x + i, y - i, z).overlay.sprite = selected;
         *  if(grid.get(x + i, y, z - i))
         *      grid.get(x + i, y, z - i).overlay.sprite = selected;
         *  if(grid.get(x, y - i, z + i))
         *      grid.get(x, y - i, z + i).overlay.sprite = selected;
         *  if(grid.get(x - i, y + i, z))
         *      grid.get(x - i, y + i, z).overlay.sprite = selected;
         *  if(grid.get(x - i, y, z + i))
         *      grid.get(x - i, y , z + i).overlay.sprite = selected;
         * }
         */
        /*Debug.
         * Handles.Label(transform.position, x + "," + y + "," + z);*/
        //Handles.Label(transform.position, "test");
    }