示例#1
0
    public void TargetCharacter(ObjBase obj)
    {
        var myself = ObjManager.Instance.MyPlayer;

        if (myself == obj)
        {
            return;
        }
        var character = obj as ObjCharacter;

        if (character == null)
        {
            return;
        }

        switch (character.GetObjType())
        {
        case OBJ.TYPE.INVALID:
            break;

        case OBJ.TYPE.OTHERPLAYER:
            if (GameSetting.Instance.ShowOtherPlayer)
            {
                TargetObj = character;
                PlayerDataManager.Instance.SetSelectTargetData(TargetObj, 3);
                EventDispatcher.Instance.DispatchEvent(new UIEvent_MainuiCloseList());
            }
            break;

        case OBJ.TYPE.NPC:

        {
            TargetObj = character;
            PlayerDataManager.Instance.SetSelectTargetData(TargetObj, 3);
            EventDispatcher.Instance.DispatchEvent(new UIEvent_MainuiCloseList());
        }
        break;

        case OBJ.TYPE.RETINUE:
            break;

        case OBJ.TYPE.DROPITEM:
            break;

        case OBJ.TYPE.AUTOPLAYER:
            break;

        case OBJ.TYPE.MYPLAYER:
            break;

        case OBJ.TYPE.FAKE_CHARACTER:
            break;

        case OBJ.TYPE.ELF:
            break;

        default:
            break;
        }
    }
示例#2
0
 public SceneObj(ObjBase parent, int?id) : base(parent, id)
 {
     Position     = Vector2.Zero;
     Scale        = 1.0f;
     DrawAtOrigin = true;
     Color        = Color.White;
 }
示例#3
0
    public ObjBase SelectNearestObj(Vector3 pos, Func <ObjBase, bool> fucn = null)
    {
        if (MyPlayer == null)
        {
            return(null);
        }

        ObjBase ret      = null;
        var     distance = -1.0f;

        {
            // foreach(var pair in mObjDict)
            var __enumerator4 = (mObjDict).GetEnumerator();
            while (__enumerator4.MoveNext())
            {
                var pair = __enumerator4.Current;
                {
                    var obj = pair.Value;
                    if (obj == null)
                    {
                        continue;
                    }
                    if (obj.GetObjType() == OBJ.TYPE.NPC)
                    {
                        var npc = obj as ObjNPC;
                        if (npc == null || npc.TableNPC == null || npc.TableNPC.Interactive != 1)
                        {
                            continue;
                        }
                    }
                    if (null != fucn)
                    {
                        if (!fucn(obj))
                        {
                            continue;
                        }
                    }
                    var diff = Vector2.Distance(obj.Position.xz(), pos.xz());
                    if (distance > 0 && diff > distance)
                    {
                        continue;
                    }
                    //增加阻挡判断(如果碰到阻挡,降低阻挡里的物体的权值)
                    NavMeshHit hit;
                    if (NavMesh.Raycast(MyPlayer.Position, obj.Position, out hit, -1))
                    {
                        if (distance > 0 && diff + ObstaclePriority > distance)
                        {
                            continue;
                        }
                    }
                    ret      = obj;
                    distance = diff;
                }
            }
        }
        return(ret);
    }
示例#4
0
    private void Update()
    {
#if !UNITY_EDITOR
        try
        {
#endif

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            PlatformHelper.Exit();
        }

        {
            var __list1      = mMgrList;
            var __listCount1 = __list1.Count;
            for (var __i1 = 0; __i1 < __listCount1; ++__i1)
            {
                var mgr = __list1[__i1];
                {
                    try
                    {
                        //  Profiler.BeginSample(mgr.GetType().ToString());
                        mgr.Tick(Time.deltaTime);
                        //  Profiler.EndSample();
                    }
                    catch
                    {
                        // some mgr failed.
                    }
                }
            }
        }

        Profiler.BeginSample("TimeManager.Updata()");
        TimeManager.Instance.Updata();
        Profiler.EndSample();

        Profiler.BeginSample("GVoiceManager.Updata()");
        GVoiceManager.Instance.Update();
        Profiler.EndSample();

        Profiler.BeginSample("AnimationUpdateFrequencyController.Tick()");
        AnimationUpdateFrequencyController.Tick();
        Profiler.EndSample();

        ObjBase.UpdateVisiblity();

#if !UNITY_EDITOR
    }

    catch (Exception ex)
    {
        Logger.Error(ex.ToString());
    }
#endif
    }
示例#5
0
    public ObjBase FindObjById(ulong objId)
    {
        ObjBase obj = null;

        if (mObjDict.TryGetValue(objId, out obj))
        {
            return(obj);
        }
        return(null);
    }
示例#6
0
    public ObjBase FindObjById(ulong objId)
    {
        ObjBase obj = null;

        if (mObjDict.TryGetValue(objId, out obj))
        {
            obj.Invisible = false;
            return(obj);
        }
        return(null);
    }
示例#7
0
    public ObjCharacter FindCharacterById(ulong objId)
    {
        ObjBase obj = null;

        if (mObjDict.TryGetValue(objId, out obj))
        {
            if (obj.IsCharacter())
            {
                return(obj as ObjCharacter);
            }
        }

        return(null);
    }
示例#8
0
        public T Create <T>(ObjBase parent = null, int?id = null) where T : ObjBase
        {
            var _obj = (T)Activator.CreateInstance(typeof(T), parent ?? Root, id);

            if (parent == null)
            {
                Root.Children.Add(_obj);
            }
            else
            {
                parent.Children.Add(_obj);
            }

            return(_obj);
        }
示例#9
0
        public T GetObject <T>(int id, ObjBase searchObj = null) where T : ObjBase
        {
            var _searchObj = searchObj ?? Root;

            foreach (var _obj in _searchObj.Children)
            {
                if (_obj.Id == id)
                {
                    return((T)_obj);
                }

                var _retObj = GetObject <T>(id, _obj);
                if (_retObj != null)
                {
                    return((T)_retObj);
                }
            }

            return(null);
        }
        public void DeepCopyPublicProperties_Test_IgnoreAttribute() {
            
            var obj = new ObjBase {
                Prop1 = "string1",
                Prop2 = "second2"
            };
            
            var obj7 = new ObjChild {
                Prop1 = "original1",
                Prop2 = "original2",
            };

            obj.DeepCopy(obj7);
            
            Assert.AreEqual("string1", obj.Prop1);
            Assert.AreEqual("second2", obj.Prop2);
            
            Assert.AreEqual("original1", obj7.Prop1);
            Assert.AreEqual("second2", obj7.Prop2);
        }
示例#11
0
 public Once1(int a, ObjBase b, IObj c, MyObj d, object e)
 {
 }
示例#12
0
 public MercCard(ObjBase parent, int?id) : base(parent, id)
 {
     Texture = GContent.Load <Texture2D>("Textures/card");
 }
示例#13
0
 public GScene()
 {
     Root = new ObjBase(null, null);
 }
示例#14
0
    private bool ShouldSelectTarget(Vector3 posPressed)
    {
        // 如果是UI,那就算了
        if (null != UICamera.mainCamera)
        {
            var nUiRay = UICamera.mainCamera.ScreenPointToRay(posPressed);
            if (Physics.Raycast(nUiRay, 100.0f, LayerMask.GetMask("UI")))
            {
                return(false);
            }
        }
        EventDispatcher.Instance.DispatchEvent(new FreeClickEvent());
        var pos = posPressed;

        if (GameLogic.Instance == null)
        {
            Logger.Error("GameLogic.Instance is null");
            return(false);
        }
        if (GameLogic.Instance.MainCamera == null)
        {
            Logger.Error("GameLogic.Instance.MainCamera is null");
            return(false);
        }

        if (GameLogic.Instance.MainCamera.active)
        {
            var l = new List <KeyValuePair <float, ObjBase> >();
            if (GameLogic.Instance != null && GameLogic.Instance.Scene != null)
            {
                var sceneObj = GameLogic.Instance.Scene.gameObject;

                GameObject target = null;

                Extension.ConvertToRenderTexturePostion(ref pos);
                var ray  = GameLogic.Instance.MainCamera.ScreenPointToRay(pos);
                var mask = LayerMask.GetMask("ObjLogic", "OtherPlayer");
                var hit  = Physics.RaycastAll(ray, 20, mask);
                for (var i = 0; i < hit.Length; ++i)
                {
                    var gameObject = hit[i].collider.gameObject;
                    if (!gameObject.transform.IsChildOf(sceneObj.transform))
                    {
                        ObjBase obj = null;
                        if (null != hit[i].collider.transform.parent)
                        {
                            obj = hit[i].collider.transform.parent.GetComponent <ObjBase>();
                        }

                        if (obj == null)
                        {
                            obj = hit[i].collider.GetComponent <ObjBase>();
                        }

                        if (obj == null)
                        {
                            continue;
                        }

                        l.Add(new KeyValuePair <float, ObjBase>(hit[i].distance, obj));
                        var npc = obj as ObjNPC;
                        if (npc && !ObjManager.Instance.MyPlayer.IsMyEnemy(npc))
                        {
                            target = npc.gameObject;
                            break;
                        }
                    }
                }

                if (l.Count > 0)
                {
                    // 最优先选NPC
                    if (target == null)
                    {
                        l.Sort((a, b) =>
                        {
                            // 优先捡东西
                            bool x = true, y = true;
                            if (a.Value is ObjCharacter)
                            {
                                x = ObjManager.Instance.MyPlayer.IsMyEnemy(a.Value as ObjCharacter);
                            }

                            if (b.Value is ObjCharacter)
                            {
                                y = ObjManager.Instance.MyPlayer.IsMyEnemy(b.Value as ObjCharacter);
                            }

                            // 优先选敌方
                            if (x && !y)
                            {
                                return(-1);
                            }
                            if (x && y)
                            {
                                // 如果都是敌方,优先选玩家
                                if (a.Value.GetObjType() == OBJ.TYPE.OTHERPLAYER &&
                                    b.Value.GetObjType() != OBJ.TYPE.OTHERPLAYER)
                                {
                                    return(-1);
                                }
                            }

                            return((int)(a.Key - b.Key));
                        });

                        target = l[0].Value.gameObject;
                    }

                    //停止当前的指令
                    SelectTarget(target, -1);
                    mSkipTime = 0.5f;

                    return(true);
                }

                return(false);
            }
        }

        return(false);
    }
示例#15
0
 public Card(ObjBase parent, int?id) : base(parent, id)
 {
 }
示例#16
0
	public float GetDistance(ObjBase other)
	{
		return (transform.localPosition - other.transform.localPosition).magnitude;
	}
示例#17
0
    private ObjBase SerchNearObj(bool hasDrop = false)
    {
        if (MainPlayer == null)
        {
            Logger.Log2Bugly("SerchNearObj  MainPlayer = null");
            return(null);
        }
        if (ObjManager.Instance == null)
        {
            Logger.Log2Bugly("SerchNearObj  ObjManager.Instance = null");
            return(null);
        }
        ObjBase targetObj = null;

        if (mIsDropFirst)
        {
            targetObj = ObjManager.Instance.SelectNearestObj(MainPlayer.Position, obj =>
            {
                if (obj.GetObjType() == OBJ.TYPE.DROPITEM)
                {
                    if (hasDrop)
                    {
                        var dropItem = obj as ObjDropItem;
                        if (dropItem != null)
                        {
                            if (dropItem.HasAutoFightMove == false && dropItem.CanPickup())
                            {
                                var control = UIManager.Instance.GetController(UIConfig.SettingUI);
                                if (
                                    (bool)
                                    control.CallFromOtherClass("CanPiackUpItem", new object[] { dropItem.GetDataId() }))
                                {
//是否可拾取这种类型物品
                                    var distance = Vector2.Distance(MainPlayer.Position.xz(), dropItem.Position.xz());
                                    if (distance > GameUtils.AutoPickUpDistance)
                                    {
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                }
                return(false);
            });
        }

        if (targetObj == null)
        {
            targetObj = ObjManager.Instance.SelectNearestObj(MainPlayer.Position, obj =>
            {
                if (obj.IsCharacter())
                {
                    var character = obj as ObjCharacter;

                    if (character == null || character.Dead || character.CharacterBaseData.Hp == 0)
                    {
                        return(false);
                    }
                    if (!MainPlayer.IsMyEnemy(character))
                    {
                        return(false);
                    }
                    if (mIsDropFirst)
                    {
                        var diff = Vector2.Distance(character.Position.xz(), MainPlayer.Position.xz());
                        if (diff > 5.0f)
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
                if (mIsDropFirst == false)
                {
                    if (obj.GetObjType() == OBJ.TYPE.DROPITEM)
                    {
                        if (hasDrop)
                        {
                            var dropItem = obj as ObjDropItem;
                            if (dropItem != null)
                            {
                                if (dropItem.HasAutoFightMove == false && dropItem.CanPickup())
                                {
                                    var control = UIManager.Instance.GetController(UIConfig.SettingUI);
                                    if (
                                        (bool)
                                        control.CallFromOtherClass("CanPiackUpItem",
                                                                   new object[] { dropItem.GetDataId() }))
                                    {
//是否可拾取这种类型物品
                                        var distance = Vector2.Distance(MainPlayer.Position.xz(), dropItem.Position.xz());
                                        if (distance > GameUtils.AutoPickUpDistance)
                                        {
                                            if (distance < GameUtils.AutoPickUpDistanceMax || mIsDropFirst)
                                            {
                                                return(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return(false);
            });
        }

        return(targetObj);
    }