Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        Game.CreateSpriteClipPack("Actor1", new Point(32, 32));
        Game.CreateSpriteClipPack("Wepon", new Point(24, 24));

        int max = 8;

        for (int i = 0; i < max; i++)
        {
            CharaCtlFourFace chr = Game.Instantiate <CharaCtlFourFace>(Game.CObj("Chara"));
            chr.transform.parent        = charaPanel;
            chr.transform.localPosition = new Vector3(i * 32 - 0.5f * max * 32, GameHelp.Random(-100, 100), 0);
            chr.transform.localScale    = Vector3.one;
            chr.id = new Point(GameHelp.Random(0, 3) * 3 + 1, GameHelp.Random(0, 1) * 4 + 1);

            chr.aimMove.v  = GameHelp.Random(10, 100);
            chr.rbc.weight = GameHelp.Random(100, 200);

            CharaBaseInfo info = new CharaBaseInfo();

            info.HP  = info.MaxHP = GameHelp.Random(100, 200);
            info.Atk = GameHelp.Random(10, 20);
            info.Def = GameHelp.Random(1, 5);

            chr.info       = info;
            chr.wp.atkType = (AtkType)GameHelp.Random(2, 3);
            chr.wp.RenewWepon();

            chrs.Add(chr);
        }

        int ranId = GameHelp.Random(0, chrs.Count - 1);

        chrs[ranId].aimMove.v  = 200;
        chrs[ranId].rbc.weight = 100;

        chrs[ranId].atkSpeed = 2.5f;
        chrs[ranId].info.Atk = 30;
        chrs[ranId].info.HP  = chrs[ranId].info.MaxHP = 200;

        camAim.Aim(chrs[ranId].transform);

        /*
         * foreach(CharaCtlFourFace chr in chrs)
         * {
         *      chr.aim=chrs[GameHelp.Random(0,chrs.Count-1)].transform;
         * }*/
    }
Exemplo n.º 2
0
    /// <summary>
    /// Open up GameHelpUI using data from GameHelp.SO parameter
    /// </summary>
    /// <param name="help"></param>
    private void SetGameHelp(GameHelp help)
    {
        if (help != null)
        {
            bool isProceed = true;
            //header
            headerText.text = help.header;
            //layout
            switch (help.layout.name)
            {
            case "HelpSingle":
                layout0Panel.gameObject.SetActive(true);
                layout0Image.sprite = help.sprite0;
                break;

            default: Debug.LogWarningFormat("Unrecognised help.layout.name \"{0}\"", help.layout.name); isProceed = false;  break;
            }
            //switch on canvas
            if (isProceed == true)
            {
                //set modal true
                GameManager.i.guiScript.SetIsBlocked(true);

                /*GameManager.i.guiScript.SetIsBlocked(true, modalLevel);
                 * //pass through data for when the confirm window is closed
                 * modalLevel = details.modalLevel;
                 * modalState = details.modalState;*/

                //set states
                GameManager.i.inputScript.SetModalState(new ModalStateData()
                {
                    mainState = ModalSubState.GameHelp
                });
                Debug.LogFormat("[UI] GameHelpUI.cs -> SetGameHelp{0}", "\n");
                //turn on GameHelp
                helpCanvas.gameObject.SetActive(true);
            }
        }
        else
        {
            Debug.LogWarning("Invalid (Game) help (Null)");
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Event Handler
    /// </summary>
    /// <param name="eventType"></param>
    /// <param name="Sender"></param>
    /// <param name="Param"></param>
    public void OnEvent(EventType eventType, Component Sender, object Param = null)
    {
        //select event type
        switch (eventType)
        {
        case EventType.GameHelpOpen:
            GameHelp gameHelp = Param as GameHelp;
            SetGameHelp(gameHelp);
            break;

        case EventType.GameHelpClose:
            CloseGameHelp();
            break;

        default:
            Debug.LogError(string.Format("Invalid eventType {0}{1}", eventType, "\n"));
            break;
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// 检查并处理动画剪辑的始末事件.
    /// </summary>
    /// <param name="ac">Ac.</param>
    /// <param name="create"> <c>true</c>:创建模式 <c>   false</c>:清除模式  </param>
    public static void CheckAnimationClipEvent(AnimationClip ac, bool create = true)
    {
        AnimationEvent[]      ae_ary      = AnimationUtility.GetAnimationEvents(ac);
        List <AnimationEvent> ae_rnc_lstt = new List <AnimationEvent>(ae_ary);

        //移除 _start && _end 事件
        for (int o = 0; o < 2; o++)
        {
            for (int i = 0; i < ae_rnc_lstt.Count; i++)
            {
                AnimationEvent ae = ae_rnc_lstt[i];
                if (ae.functionName == "_start" && ae.time == 0)
                {
                    ae_rnc_lstt.RemoveAt(i);
                }
                else if (ae.functionName == "_end" && ae.time == ac.length)
                {
                    ae_rnc_lstt.RemoveAt(i);
                }
            }
        }

        //添加 _start && _end 事件
        if (create)
        {
            AnimationEvent e = new AnimationEvent();
            e.functionName    = "_start";
            e.time            = 0f;
            e.stringParameter = ac.name;
            ae_rnc_lstt.Add(e);

            e = new AnimationEvent();
            e.functionName = "_end";
            e.time         = ac.length;
            ae_rnc_lstt.Add(e);
        }

        ae_ary = GameHelp.ListToArray <AnimationEvent>(ae_rnc_lstt);
        AnimationUtility.SetAnimationEvents(ac, ae_ary);
    }
Exemplo n.º 5
0
    void OnStart()
    {
        //清除地图
        ClearMap();

        //重定义地图尺寸
        //mapSize=new Point(GameHelp.Random(5,10),GameHelp.Random(5,10));
        mapSize = new Point(10, 10);

        //选择起始点
        pre = new Point(GameHelp.Random(0, mapSize.x), GameHelp.Random(0, mapSize.y));

        //初始化地图寄存数组
        rnc_ary = new RoomNodeCtl[mapSize.x, mapSize.y];

        //地图中心偏移
        float mdx = (mapSize.x * 0.5f);
        float mdy = (mapSize.y * 0.5f);

        //最右边和最下边 索引
        int l_x = mapSize.x - 1;
        int l_y = mapSize.y - 1;

        //房间图块尺寸
        float size     = 180f;
        float halfSize = size * 0.5f;

        //先创建基本房间矩阵
        for (int i = 0; i < mapSize.x; i++)
        {
            bool far = false;
            bool fad = false;

            for (int o = 0; o < mapSize.y; o++)
            {
                int e_x = i - 1;
                int e_y = o - 1;

                //创建房间物体
                GameObject go = GameObject.Instantiate(Game.SObj("Node")) as GameObject;
                go.transform.parent        = nodeRoot;
                go.transform.localPosition = new Vector3((i - mdx) * size + halfSize, (mdy - o) * size - halfSize, 0);
                go.transform.localScale    = Vector3.one;
                RoomNodeCtl  rnc = go.GetComponent <RoomNodeCtl>();
                ButtonMsgObj bmo = go.GetComponent <ButtonMsgObj>();
                bmo.value     = rnc;
                bmo.target    = this.gameObject;
                rnc_ary[i, o] = rnc;
                rnc.id        = new Point(i, o);
                rnc_lst.Add(rnc);

                //SpriteRenderer sr=go.transform.Find("spt").GetComponent<SpriteRenderer>();

                if (!(i == l_x && o == l_y))
                {
                    //分布随机右或下连接点
                    bool r = (GameHelp.Random());
                    bool d = (GameHelp.Random());
                    if (r == false && d == false)
                    {
                        if ((GameHelp.Random()))
                        {
                            r = true;
                        }
                        else
                        {
                            d = true;
                        }
                    }

                    if (i == l_x)
                    {
                        r = false;
                        if (!rnc_ary[e_x, o].right)
                        {
                            d = true;
                        }
                    }

                    if (o == l_y)
                    {
                        d = false;
                        if (!rnc_ary[i, e_y].down)
                        {
                            r = true;
                        }
                    }

                    CreateLine(r, d, rnc);
                    rnc_ary[i, o].right = r; rnc_ary[i, o].down = d;
                }
                //添加到剩余ids
                lSid.Add(new Point(i, o));
            }
        }

        //补位 能够减少通道计算损耗--------------------------------------------------
        //右下角
        if (rnc_ary[mapSize.x - 1, mapSize.y - 2].down == false && rnc_ary[mapSize.x - 2, mapSize.y - 1].right == false)
        {
            if (GameHelp.Random())
            {
                rnc_ary[mapSize.x - 1, mapSize.y - 2].down = true;
            }
            else
            {
                rnc_ary[mapSize.x - 2, mapSize.y - 1].right = true;
            }
        }

        //右上角
        if (rnc_ary[mapSize.x - 2, 0].right == false && rnc_ary[mapSize.x - 1, 0].down == false)
        {
            if (GameHelp.Random())
            {
                rnc_ary[mapSize.x - 2, 0].right = true;
            }
            else
            {
                rnc_ary[mapSize.x - 1, 0].down = true;
            }
        }

        //相机锁定pre位置
        //cam.transform.localPosition=rnc_ary[(int)pre.x,(int)pre.y].transform.parent.localPosition;

        //临时ids总通道集
        List <List <Point> > allSid = new List <List <Point> >();

        //搜索出所有的通道集
        while (lSid.Count > 0)
        {
            RoomNodeCtl rnc = rnc_ary[lSid[0].x, lSid[0].y];
            hSid = new List <Point>();

            hSid.Add(rnc.id);
            Find(rnc);
            allSid.Add(hSid);
            RemoveSid(hSid);

            //给找到的通道染色
            Color c = new Color(Random.Range(0.5f, 1f), Random.Range(0.5f, 1f), Random.Range(0.5f, 1f));
            foreach (Point id in hSid)
            {
                rnc_ary[id.x, id.y].spt.color = c;
            }
        }

        //选取维度最高通道作为主要通道
        int          max       = int.MinValue;
        List <Point> mainSid   = null;
        int          mainSidId = 0;

        for (int i = 0; i < allSid.Count; i++)
        {
            if (allSid[i].Count > max)
            {
                max       = allSid[i].Count;
                mainSidId = i;
            }
        }

        //从全通道列表中移除主要通道
        mainSid = allSid[mainSidId];
        allSid.RemoveAt(mainSidId);

        //给主通道染色
        foreach (Point id in mainSid)
        {
            rnc_ary[id.x, id.y].spt.color = new Color(0, 0.8f, 1f);
        }

        //剩余通道与主要通道进行融合
        int e = 0;

        Debug.Log("剩余通道数量:" + allSid.Count);

        while (allSid.Count > 0)
        {
            //寻找目前可以连接到主通道的剩余通道
            List <Point> rnc_str = allSid[e];
            Debug.Log("通道[" + e + "]数量:" + rnc_str.Count);

            /*	foreach(Point id in rnc_str)
             *      {
             *              rnc_ary[id.x,id.y].spt.color=new Color(1f,1f,0.5f);
             *      }*/

            for (int o = 0; o < rnc_str.Count; o++)
            {
                Point id = rnc_str[o];
                List <NodeConnect> nc_lst = new List <NodeConnect>();

                Debug.Log("id:" + id.ToString());

                //查找与主通道可以连接的接口
                if (id.x < mapSize.x - 1)
                {
                    if (mainSid.Contains(new Point(id.x + 1, id.y)))
                    {
                        nc_lst.Add(new NodeConnect(id.x, id.y, NodeConnect.TYPE.RIGHT));
                    }
                }
                if (id.y < mapSize.y - 1)
                {
                    if (mainSid.Contains(new Point(id.x, id.y + 1)))
                    {
                        nc_lst.Add(new NodeConnect(id.x, id.y, NodeConnect.TYPE.UP));
                    }
                }
                if (id.x > 0)
                {
                    if (mainSid.Contains(new Point(id.x - 1, id.y)))
                    {
                        nc_lst.Add(new NodeConnect(id.x, id.y, NodeConnect.TYPE.LEFT));
                    }
                }
                if (id.y > 0)
                {
                    if (mainSid.Contains(new Point(id.x, id.y - 1)))
                    {
                        nc_lst.Add(new NodeConnect(id.x, id.y, NodeConnect.TYPE.DOWN));
                    }
                }

                //存在至少一个接口
                if (nc_lst.Count > 0)
                {
                    Debug.Log("接口数量:" + nc_lst.Count);


                    //取任意一个连接位
                    NodeConnect nc = nc_lst[GameHelp.Random(0, nc_lst.Count - 1)];
                    Debug.Log(nc.id.ToString() + "  " + nc.type);
                    //连接可连接位
                    if (nc.type == NodeConnect.TYPE.RIGHT)
                    {
                        rnc_ary[nc.id.x, nc.id.y].right = true;
                    }
                    else if (nc.type == NodeConnect.TYPE.LEFT)
                    {
                        rnc_ary[nc.id.x - 1, nc.id.y].right = true;
                    }
                    else if (nc.type == NodeConnect.TYPE.DOWN)
                    {
                        rnc_ary[nc.id.x, nc.id.y - 1].down = true;
                    }
                    else if (nc.type == NodeConnect.TYPE.UP)
                    {
                        rnc_ary[nc.id.x, nc.id.y].down = true;
                    }

                    //将当前通道添加到主通道
                    AddSid(rnc_str, mainSid);

                    //从剩余通道中移除当前通道
                    allSid.RemoveAt(e);
                    break;
                }
            }

            e++;
            if (e >= allSid.Count)
            {
                e = 0;
            }
        }

        DistributionRoomType();

        //GetDepth(pre,pre,out aim);

        /*
         * Transform aim_trs= rnc_ary[(int)aim.x,(int)aim.y].transform;
         * Transform pre_trs= rnc_ary[(int)pre.x,(int)pre.y].transform;
         *
         * pre_trs.GetComponent<SpriteRenderer>().color=new Color(1f,0.65f,0.0f,2);
         * pre_trs.parent.transform.Find("spt").localScale=new Vector3(96,96,1);
         *
         * aim_trs.GetComponent<SpriteRenderer>().color=new Color(0.15f,1,0.25f,2);
         * aim_trs.parent.transform.Find("spt").localScale=new Vector3(96,96,1);
         */
        //cam_m.SetLocalAim(Vector3.zero);
    }
Exemplo n.º 6
0
 void Awake()
 {
     instance = this;
 }
Exemplo n.º 7
0
    void Update()
    {
        if (info.HP == 0 && living)
        {
            aimMove.update = false;
            aimMove.move   = false;

            rbc.enabled = false;
            living      = false;

            GameObject go = GameObject.Instantiate(Game.EObj("DieEff")) as GameObject;

            go.transform.parent        = Game.SRTM <BattleSRTM>().charaPanel;
            go.transform.localPosition = this.transform.localPosition;
            go.transform.localScale    = Vector3.one;

            Destroy(this.gameObject);
            Game.SRTM <BattleSRTM>().chrs.Remove(this);
        }

        if (aim != null)
        {
            if (!aim.living)
            {
                aim = null;
            }
        }

        spt.depth    = -(int)transform.localPosition.y;
        wp.spt.depth = spt.depth + 1;


        if (living)
        {
            if (aim != null)
            {
                Vector3 dis    = aim.transform.localPosition - transform.localPosition;
                Vector3 aimPos = aim.transform.localPosition;

                if (wp.atkType == AtkType.Shooting)
                {
                    aimPos = dis.normalized * (dis.magnitude - wp.atkRange);
                }



                aimMove.Aim(aimPos, true);

                Vector2 v2 = new Vector2(dis.x, dis.y);
                angle = Vector2.Angle(Vector2.up, v2); if (dis.x < 0)
                {
                    angle = 360 - angle;
                }
                ;
                wp.RenewAngle(angle);

                if (!atkState)
                {
                    if (atkTimer > 1f / atkSpeed)
                    {
                        atkState = true;
                        atkTimer = 0f;
                    }
                    else
                    {
                        atkTimer += Game.RealDeltaTime(true);
                    }
                }
                else
                {
                    float range = dis.magnitude;
                    //angle=aimMove.Angle;


                    if (wp.CheckToAtk(range, atkSpeed))
                    {
                        atkState = false;
                    }
                }
            }
            else
            {
                angle = aimMove.Angle;

                FindNewAim();

                if (aim == null)
                {
                    if (!aimMove.move)
                    {
                        aimMove.v = GameHelp.Random(50, 80);
                        aimMove.Aim(transform.localPosition + new Vector3(Random.Range(-50, 50), Random.Range(-50, 50), 0), true);
                    }
                }
            }


            if (angle > 45 && angle <= 135)
            {
                SwapFace(FACE.RIGHT);
            }
            else if (angle > 135 && angle <= 225)
            {
                SwapFace(FACE.DOWN);
            }
            else if (angle > 225 && angle <= 315)
            {
                SwapFace(FACE.LEFT);
            }
            else
            {
                SwapFace(FACE.UP);
            }
        }
    }