public void Handle(FrameOpt opt)
    {
        if (opt == null)
        {
            Debug.Log("why null?");
        }
        //Debug.Log("handle:");
        switch (opt.optType)
        {
        case eOptType.MVOE:
            string optContent = opt.optContent;
            //Debug.Log(realOpt.Velocity);
            if (optContent != null)
            {
                LogicActor target = GetActor(opt.actorId);
                if (target != null)
                {
                    string[] vString = optContent.Split(',');

                    target.Volocity = new VInt2(int.Parse(vString[0]), int.Parse(vString[1]));
                }
            }
            break;

        default:
            break;
        }
    }
Exemple #2
0
    public void Update(int dtime)
    {
        LastPos = Pos;
        //dtime 单位毫秒 speed 单位 多少(0.001)格 每(毫)秒
        Vector2 dir     = new Vector2(Volocity.x, Volocity.y);
        VInt2   trueDir = (VInt2)(dir.normalized);

        LogicDiff = new VInt2(trueDir.x * dtime * speed / 1000, trueDir.y * dtime * speed / 1000); //new VInt2(Volocity.x * dtime * speed, Volocity.y * dtime * speed);

        if (Volocity.x == 0 && Volocity.y == 0)
        {
            SwitchState(eState.IDLE);
        }
        else
        {
            SwitchState(eState.MOVE);
        }
        //在这里 判断攻击打出来

        //Volocity * dtime
        Pos = LastPos + LogicDiff;

        Volocity = VInt2.zero;


        if (viewActor != null)
        {
            viewActor.UpdateVec();
        }



        if (viewActor != null)
        {
            List <Actor> ll = viewActor.contactActors;
            for (int i = 0; i < ll.Count; i++)
            {
                LogicActor other = ll[i].bindLogicActor;
                Debug.Log("碰" + other.ActorId);
            }
        }
    }
    public static LogicActor CreateNewActor(string name)
    {
        LogicActor logicActor = new LogicActor();

        Actor actor = null;

        if (name == "pawn")
        {
            GameObject prefab = Resources.Load("Pawn") as GameObject;
            GameObject inst   = GameObject.Instantiate(prefab);
            actor = inst.GetComponent <Actor>();
            actor.Init(logicActor);
            logicActor.viewActor = actor;
        }
        if (actor)
        {
            GameMain.GetInstance().viewManager.GameActors.Add(actor);
        }
        return(logicActor);
    }
 public void AddActor(LogicActor logicActor)
 {
     LogicActorMap[logicActor.ActorId] = logicActor;
     LogicActorList.Add(logicActor);
 }
Exemple #5
0
 public void Init(LogicActor logicActor)
 {
     this.bindLogicActor = logicActor;
 }
Exemple #6
0
 public void ChangePawn(LogicActor newPawn)
 {
     this.Pawn = newPawn;
 }