Beispiel #1
0
    public void Create(FightCtllerView ctl, FightGrid grid)
    {
        m_ctller = ctl;
        m_fight_grid = grid;

        Vector2 min = new Vector2(float.MaxValue, float.MaxValue);
        Vector2 max = new Vector2(float.MinValue, float.MinValue);

        m_units = new Unit[FightGrid.UnitCount.Y, FightGrid.UnitCount.X];
        for (int y = 0; y < FightGrid.UnitCount.Y; ++y)
        {
            for (int x = 0; x < FightGrid.UnitCount.X; ++x)
            {
                GameObject obj_unit = ResMgr.Instance.CreateGameObject("Fight/GridUnit", gameObject);
                obj_unit.transform.localPosition = grid.Units[y, x].Position * Launcher.SpriteScale;
                FightGridUnitView uv = obj_unit.GetComponent<FightGridUnitView>();
                uv.Create(this, grid.Units[y, x]);
                m_units[y, x] = new Unit(new Int2D(x, y), uv);

                min.x = Mathf.Min(min.x, grid.Units[y, x].Position.x - FightGrid.UnitSize / 2);
                min.y = Mathf.Min(min.y, grid.Units[y, x].Position.y - FightGrid.UnitSize / 2);

                max.x = Mathf.Max(max.x, grid.Units[y, x].Position.x + FightGrid.UnitSize / 2);
                max.y = Mathf.Max(max.y, grid.Units[y, x].Position.y + FightGrid.UnitSize / 2);
            }
        }
        min *= Launcher.SpriteScale;
        max *= Launcher.SpriteScale;
        BoxCollider cld = gameObject.AddComponent<BoxCollider>();
        cld.center = min + (max - min) / 2;
        cld.size = (max - min);

        m_fight_grid.OnAddCreature += OnAddCreature;
    }
Beispiel #2
0
    void SetupFightCtller()
    {
        //ResMgr.Instance.CreateGameObject("BG/BG01", gameObject);

        m_fc = new FightCtller();
        m_fc.Create();

        GameObject ctl = Util.NewGameObject("FCtller", CanvasUI.gameObject);

        m_fcv = ctl.AddComponent <FightCtllerView>();
        m_fcv.Create(m_fc);

        string[] keys = null;
        Int2D[]  pts  = null;

        keys = new string[] { "Hadis", "Cretos", "Aflotiter", "Bosadon", "Giant", "Bosadon", "Bosadon", "Bosadon", "Bosadon" };
        pts  = new Int2D[] { new Int2D(0, 0), new Int2D(2, 0), new Int2D(0, 1), new Int2D(2, 1), new Int2D(3, 1), new Int2D(4, 1), new Int2D(2, 2), new Int2D(3, 2), new Int2D(4, 2) };
        for (int p = 0; p < keys.Length; ++p)
        {
            string       k    = keys[p];
            InfoCreature info = new InfoCreature(ProtoMgr.Instance.GetByKey <ProtoCreature>(k));
            info.Skills = new InfoSkill[info.Proto.Skills.Length];
            for (int s = 0; s < info.Skills.Length; ++s)
            {
                info.Skills[s] = new InfoSkill(ProtoMgr.Instance.GetByID <ProtoSkill>(info.Proto.Skills[s]));
            }


            Creature ac = new Creature();
            ac.Create(info);
            m_fc.FGrids[0].AddCreature(ac, pts[p]);
        }

        keys = new string[] { "Hadis", "Kerboros", "Aflotiter", "Bosadon", "Giant", "Bosadon", "Bosadon", "Cretos" };
        pts  = new Int2D[] { new Int2D(0, 0), new Int2D(2, 0), new Int2D(3, 0), new Int2D(0, 1), new Int2D(1, 1), new Int2D(0, 2), new Int2D(1, 2), new Int2D(2, 2) };
        for (int p = 0; p < keys.Length; ++p)
        {
            string       k    = keys[p];
            InfoCreature info = new InfoCreature(ProtoMgr.Instance.GetByKey <ProtoCreature>(k));
            info.Skills = new InfoSkill[info.Proto.Skills.Length];
            for (int s = 0; s < info.Skills.Length; ++s)
            {
                info.Skills[s] = new InfoSkill(ProtoMgr.Instance.GetByID <ProtoSkill>(info.Proto.Skills[s]));
            }

            Creature ac = new Creature();
            ac.Create(info);
            m_fc.FGrids[1].AddCreature(ac, pts[p]);
        }

        m_fc.Idle();
    }
Beispiel #3
0
    void SetupFightCtller()
    {
        //ResMgr.Instance.CreateGameObject("BG/BG01", gameObject);

        m_fc = new FightCtller();
        m_fc.Create();

        GameObject ctl = Util.NewGameObject("FCtller", RootSprite);
        m_fcv = ctl.AddComponent<FightCtllerView>();
        m_fcv.Create(m_fc);

        string[] keys = null;
        Int2D[] pts = null;

        keys = new string[] { "M01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01" };
        pts = new Int2D[] { new Int2D(0, 0), new Int2D(2, 0), new Int2D(3, 0), new Int2D(4, 0), new Int2D(0, 1), new Int2D(1, 1), new Int2D(2, 1), new Int2D(3, 1), new Int2D(4, 1), new Int2D(0, 2), new Int2D(1, 2), new Int2D(2, 2), new Int2D(3, 2), new Int2D(4, 2)};
        for (int p = 0; p < keys.Length; ++ p)
        {
            string k = keys[p];
            InfoCreature info = new InfoCreature(ProtoMgr.Instance.GetByKey<ProtoCreature>(k));

            Creature ac = new Creature();
            ac.Create(info);
            m_fc.FGrids[0].AddCreature(ac, pts[p]);
        }

        keys = new string[] { "M01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01", "N01" };
        pts = new Int2D[] { new Int2D(0, 0), new Int2D(2, 0), new Int2D(3, 0), new Int2D(4, 0), new Int2D(0, 1), new Int2D(1, 1), new Int2D(2, 1), new Int2D(3, 1), new Int2D(4, 1), new Int2D(0, 2), new Int2D(1, 2), new Int2D(2, 2), new Int2D(3, 2), new Int2D(4, 2) };
        for (int p = 0; p < keys.Length; ++p)
        {
            string k = keys[p];
            InfoCreature info = new InfoCreature(ProtoMgr.Instance.GetByKey<ProtoCreature>(k));
            //info.Guns = new InfoGun[info.Proto.Guns.Length];
            //for (int i = 0; i < info.Guns.Length; ++i)
            //{
            //    info.Guns[i] = new InfoGun(info.Proto.ProtoGuns[i]);
            //}

            Creature ac = new Creature();
            ac.Create(info);
            m_fc.FGrids[1].AddCreature(ac, pts[p]);
        }

        m_fc.Fight();
    }
Beispiel #4
0
    public void Create(FightCtllerView ctl, FightGrid grid)
    {
        m_ctller         = ctl;
        m_fight_grid     = grid;
        gameObject.layer = (int)UnityLayer.UI;

        Vector2 min = new Vector2(float.MaxValue, float.MaxValue);
        Vector2 max = new Vector2(float.MinValue, float.MinValue);

        m_units = new Unit[FightGrid.UnitCount.Y, FightGrid.UnitCount.X];
        for (int y = 0; y < FightGrid.UnitCount.Y; ++y)
        {
            for (int x = 0; x < FightGrid.UnitCount.X; ++x)
            {
                GameObject obj_unit = ResMgr.Instance.CreateGameObject("Fight/GridUnit", gameObject);
                obj_unit.transform.localPosition = grid.Units[y, x].Position;
                FightGridUnitView uv = obj_unit.GetComponent <FightGridUnitView>();
                uv.Create(this, grid.Units[y, x]);
                m_units[y, x] = new Unit(new Int2D(x, y), uv);

                min.x = Mathf.Min(min.x, grid.Units[y, x].Position.x - FightGrid.UnitSize / 2);
                min.y = Mathf.Min(min.y, grid.Units[y, x].Position.y - FightGrid.UnitSize / 2);

                max.x = Mathf.Max(max.x, grid.Units[y, x].Position.x + FightGrid.UnitSize / 2);
                max.y = Mathf.Max(max.y, grid.Units[y, x].Position.y + FightGrid.UnitSize / 2);
            }
        }

        /*
         * BoxCollider cld = gameObject.AddComponent<BoxCollider>();
         * cld.center = min + (max - min) / 2;
         * cld.size = (max - min);
         */
        SetVisible(false);

        m_fight_grid.OnAddCreature    += OnAddCreature;
        m_fight_grid.OnRemoveCreature += OnRemoveCreature;
    }