Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        float distance;
        if (Physics.Raycast (new Ray (CameraFacing.transform.position,
                                      CameraFacing.transform.rotation * Vector3.forward),
                             out hit)) {
            distance = hit.distance;
            if (hit.transform.GetComponent<InteractiveObj> () != null && hit.transform.tag != "Background") {
                interactiveObj = hit.transform.GetComponent<InteractiveObj> ();
                interactiveObj.objectHit = true;
                objectViewing = hit.transform.gameObject;
                //print ("Hitting Something");
            } else{
                if(interactiveObj != null){
                    //print ("Hitting Nothing");
                    interactiveObj.objectHit = false;
                    objectViewing = null;
                }

            }
        } else {
            distance = CameraFacing.farClipPlane * 0.95f;
        }
        transform.position = CameraFacing.transform.position +
            CameraFacing.transform.rotation * Vector3.forward;
        transform.LookAt (CameraFacing.transform.position);
        transform.Rotate (0.0f, 180.0f, 0.0f);
        if (distance < 10.0f) {
            distance *= 1 + 5*Mathf.Exp (-distance);
        }
        //transform.localScale = originalScale * distance;
    }
Esempio n. 2
0
 protected override void OnExecute(InteractiveObj self, Vector3 pos)
 {
     foreach (var target in BattleManager.Instance.dicInteractiveObjs.Values)
     {
         if (target && self.IsEnemy(target.Camp) && Common.IsPosInConeRange(self.transform, pos, Angle, MaxRange, MinRange))
         {
             target.DoDamage(new Damage(EffectType, self.CalAtkDamage(EffectBaseValue)), self);
         }
     }
 }
Esempio n. 3
0
 protected override void OnDamage(Damage damage, InteractiveObj source)
 {
     base.OnDamage(damage, source);
     Role.PlayAction(Role.strDamageAnimName, 0.1f);
     if (!ForceTarget && !IsForceMove && source && source != WorldInteractObj.Instance)
     {
         CurrentTarget = source;
         OnFightBegin.Invoke();
         ChaseTarget();
     }
 }
Esempio n. 4
0
    public void OnTrigger(Collider other)
    {
        if (!Master.IsAlive || !BattleManager.Instance.IsBattleBegin)
        {
            return;
        }
        Q_SceneObj sceneObj = other.GetComponent <Q_SceneObj>();

        if (sceneObj)
        {
            switch (sceneObj.objType)
            {
            case Q_SceneObj.Type.Skill:
                SkillEffectBase[] skillEffects = sceneObj.GetComponentsInChildren <SkillEffectBase>(true);
                for (int i = 0, length = skillEffects.Length; i < length; ++i)
                {
                    skillEffects[i].Execute(WorldInteractObj.Instance, Master);
                }
                sceneObj.UseObj();
                break;

            case Q_SceneObj.Type.GuidePoint:
                sceneObj.UseObj();
                UISystem.Instance.ShowGuideDialog(sceneObj.name);
                break;

            case Q_SceneObj.Type.TriggerPoint:
                sceneObj.UseObj();
                break;

            case Q_SceneObj.Type.LoadScene:
                sceneObj.UseObj();
                GameClient.Instance.LoadScene(sceneObj.strNeedItemName);
                break;

            case Q_SceneObj.Type.Vedio:
                VedioPlayer.Play(sceneObj.strNeedItemName, null);
                sceneObj.gameObject.SetActive(false);
                sceneObj.UseObj();
                break;

            case Q_SceneObj.Type.SuccessPoint:
                sceneObj.UseObj();
                BattleManager.Instance.BattleOver(true);
                break;
            }
        }
        InteractiveObj target = other.GetComponent <InteractiveObj>();

        if (target && target.IsAlive && target.IsEnemy(ThirdPersonPlayer.Instance.Camp))
        {
            ThirdPersonPlayer.Instance.DoDamage(new Damage(WorldSetting.Effect.Physical, 1), target);
        }
    }
Esempio n. 5
0
    //**********************弹窗相关************************


    public int ShowPopUp(GameObject thePopup, InteractiveObj tpopupObj)
    {
        int t = thePopupController.ShowPopUp(thePopup, tpopupObj);

        if (t == 0)
        {
            //SetIsGlobalObjRespondMouse(false);
        }

        return(t);
    }
Esempio n. 6
0
 protected override void OnExecute(InteractiveObj self, Vector3 pos)
 {
     RaycastHit[] hits = Physics.SphereCastAll(pos, Range, Vector3.up, float.MaxValue, layerEnemey);
     for (int i = 0, length = hits.Length; i < length; ++i)
     {
         InteractiveObj target = hits[i].collider.GetComponent <InteractiveObj>();
         if (target && self.IsEnemy(target.Camp))
         {
             target.DoDamage(new Damage(EffectType, self.CalAtkDamage(EffectBaseValue)), self);
         }
     }
 }
Esempio n. 7
0
    void CheckOpenedChestPos()
    {
        if (curObj == null)
        {
            return;
        }

        if (!IsCloseToPlayer(curObj))
        {
            curObj = curObj.Interact();
        }
    }
Esempio n. 8
0
 public void Execute(InteractiveObj self, Vector3 pos)
 {
     GameClient.Instance.NextTick(() =>
     {
         if (!self)
         {
             return;
         }
         EffectPlayer.PlayAtPos(EffectFX, pos);
         AudioSystem.Instance.PlayAtPos(EffectSE, pos);
         OnExecute(self, pos);
     }, EffectDelay / 1000f);
 }
Esempio n. 9
0
 protected InteractiveObj FindTargetByPos(InteractiveObj self, Vector3 pos, int range = DefaultEffectRange)
 {
     RaycastHit[] hits = Physics.SphereCastAll(pos, range, Vector3.up, float.MaxValue, layerEnemey);
     for (int i = 0, length = hits.Length; i < length; ++i)
     {
         InteractiveObj target = hits[i].collider.GetComponent <InteractiveObj>();
         if (target && self.IsEnemy(target.Camp))
         {
             return(target);
         }
     }
     return(null);
 }
Esempio n. 10
0
    protected override void OnExecute(InteractiveObj self, InteractiveObj target)
    {
        target.DoDamage(new Damage(EffectType, self.CalAtkDamage(EffectBaseValue)), self);
        EffectPlayer.PlayOnTransform(EffectFX, target.BeAtkPoint);
        AudioSystem.Instance.PlayOnTransform(EffectSE, target.BeAtkPoint);

        Debuff_Dot dot = new Debuff_Dot();

        dot.Init(nBuffOrder, nDuration, BuffBase.Type.Debuff, self, target);
        dot.InitDot(nFirstEffectTime, nDuration, EffectType, self.CalAtkDamage(nEffectDamage), self.CalAtkDamage(nEndDamage));
        dot.InitDotResources(objContinueFX, acContinueSE, objContinueEffectFX, acContinueEffectSE, objEndEffectFX, acEndEffectSE);
        target.AddBuff(dot);
    }
Esempio n. 11
0
 public void Execute(InteractiveObj self, InteractiveObj target)
 {
     GameClient.Instance.NextTick(() =>
     {
         if (!target)
         {
             return;
         }
         EffectPlayer.PlayOnTransform(EffectFX, target.BeAtkPoint);
         AudioSystem.Instance.PlayAtPos(EffectSE, target.BeAtkPoint.position);
         OnExecute(self, target);
     }, EffectDelay / 1000f);
 }
Esempio n. 12
0
 public void DoDamage(Damage damage, InteractiveObj source)
 {
     if (!IsAlive || damage.value == 0)
     {
         return;
     }
     OnDamage(damage, source);
     AddFightingEnemey(source);
     if (HP < 1)
     {
         Death();
     }
 }
Esempio n. 13
0
    void Add(InteractiveObj iObj)
    {
        ObjectInteraction oi = iObj.OnCloseEnough;

        switch(oi.interactionType)
        {
            case (ObjectInteraction.InteractionType.Unique):
                Insert(iObj);
                break;

            case (ObjectInteraction.InteractionType.Accumulate):
                bool inserted = false;

                // find object of same type to increase the count.
            CustomGameObj cgo = iObj.gameObject.GetComponent<CustomGameObj>();
            CustomGameObj.CustomGameObjectType ot = CustomGameObj.CustomGameObjectType.Invalid;

            if (cgo != null) {
                ot = cgo.objectType;
            }

            for (int i = 0; i < inventoryObjects.Count; i++) {
                CustomGameObj cgoi = inventoryObjects[i].item.GetComponent<CustomGameObj>();
                CustomGameObj.CustomGameObjectType io = CustomGameObj.CustomGameObjectType.Invalid;
                if (cgoi != null)
                {
                    io = cgoi.objectType;
                }

                if (ot == io)
                {
                    inventoryObjects[i].quantity++;
                    // add token from this object to mission Manager to track it
                    MissionToken mt = iObj.gameObject.GetComponent<missionToken>();
                    if (mt != null) {
                        _missionMgr.add(mt);
                    }

                    iObj.gameObject.SetActive(false);
                    inserted = true;
                    break;
                }
            }

            // if we get this far, it means a dupe was found in the inventory!
            if (inserted) {
                Insert(iObj);
            }
                break;
        }
    }
Esempio n. 14
0
 protected override void OnInit(InteractiveObj obj)
 {
     MasterChara = obj as Character;
     Follow      = obj.GetComponent <CharacterFollow>();
     MasterChara.WillNotBeFind = true;
     VedioPlayer.OnVedioFinished.AddListener(() =>
     {
         _start = true;
         MasterChara.Role.PlayAction("Hello", 0);
         Vector3 pos = ThirdPersonPlayer.Instance.transform.position;
         pos.y       = MasterChara.transform.position.y;
         MasterChara.transform.LookAt(pos);
     });
 }
Esempio n. 15
0
 protected override void OnDamage(Damage damage, InteractiveObj source)
 {
     if (IsProtected)
     {
         IsProtected = false;
         return;
     }
     base.OnDamage(damage, source);
     Role.PlayAction(Role.strDamageAnimName, 0.1f);
     if (CameraController.MainCamera)
     {
         CameraController.MainCamera.transform.DOShakePosition(0.3f, new Vector3(0.12f, 0.12f), 20);
     }
 }
    public void Add(InteractiveObj iObj)
    {
        ObjectInteraction oi = iObj.OnCloseEnough;

        switch (oi.interactionType)
        {
        case ObjectInteraction.InteractionType.Unique:
            Insert(iObj);
            break;

        case ObjectInteraction.InteractionType.Accumulate:
        {
            bool          inserted             = false;
            CustomGameObj cgo                  = iObj.gameObject.GetComponent <CustomGameObj> ();
            CustomGameObj.CustomObjectType cot = CustomGameObj.CustomObjectType.Invalid;
            if (cgo != null)
            {
                cot = cgo.objectType;                         // type
            }
            for (int i = 0; i < inventoryItems.Count; i++)
            {
                CustomGameObj cgoi = inventoryItems[i].item.GetComponent <CustomGameObj> ();
                CustomGameObj.CustomObjectType coti = CustomGameObj.CustomObjectType.Invalid;
                if (cgoi != null)
                {
                    coti = cgoi.objectType;               // type
                }
                if (cot == coti)                          //accumulate
                {
                    inventoryItems [i].quantity++;
                    //deal with mission token
                    MissionToken mt = iObj.gameObject.GetComponent <MissionToken> ();
                    if (mt != null)
                    {
                        missionMgr.Add(mt);
                        iObj.gameObject.SetActive(false);
                        inserted = true;
                        break;
                    }
                }                //if(cot == coti)
            }                    //for (

            if (!inserted)
            {
                Insert(iObj);
            }
        }        //accumulate
        break;
        }        //switch
    }
Esempio n. 17
0
 public int ShowPopUp(GameObject thePopup, InteractiveObj tpopupObj)
 {
     if (!isShowPopup)
     {
         popupObj    = tpopupObj;
         isShowPopup = true;
         nowPropup   = Instantiate(thePopup, transform);
         backGround.SetActive(true);
         return(0);
     }
     else
     {
         return(-1);
     }
 }
Esempio n. 18
0
    public void AttackTarget(InteractiveObj tar, float offsetAngle)
    {
        ForceTarget = tar;
        Vector3 vecTargetPos = tar.transform.position;

        if (vecTargetPos.SqrDistanceWith(transform.position) <= fAttackMinRange * fAttackMinRange)
        {
            return;
        }
        float distance = fAttackMinRange *= Mathf.Sign(transform.position.x - vecTargetPos.x);

        vecTargetPos.x += distance * Mathf.Cos(offsetAngle);
        vecTargetPos.z += distance * Mathf.Sin(offsetAngle);
        MoveTo(ForceTarget.ColliderSelf.ClosestPoint(vecTargetPos) + (vecTargetPos - ForceTarget.transform.position) * 0.9f);
    }
Esempio n. 19
0
    public CastResult Execute(InteractiveObj target)
    {
        Target = target;
        if (Target)
        {
            TargetPos = Target.BeAtkPoint.position;
        }
        CastResult result = OnExucete();

        if (result != CastResult.Success)
        {
            Target = null;
        }
        return(result);
    }
Esempio n. 20
0
 public void HandleInteraction()
 {
     if (interactionAction == InteractionAction.PutInInventory)
     {
         if (inventoryManager)
         {
             //TODO: inventoryManager.Add(this.gameObject.GetComponent<InteractiveObj>());
             GameObject     go   = this.gameObject;
             InteractiveObj iObj = go.GetComponent <InteractiveObj> ();
             Debug.Log("In ObjectInteraction.HandleInteraction:");
             Debug.Log(iObj);
             //inventoryManager.Add(this.gameObject.GetComponent<InteractiveObj>());
             inventoryManager.Add(iObj);
         }
     }
 }
Esempio n. 21
0
 public void Init(InteractiveObj master)
 {
     Master    = master;
     RigidSelf = GetComponentInChildren <Rigidbody>();
     RigidSelf.GetComponent <SceneRotateWorldButton>().Init(this);
     RigidSelf.gameObject.SetActive(false);
     RigidFake = GetComponentInChildren <Rigidbody2D>();
     RigidFake.GetComponent <SceneRotateFakeButton>().Init(this);
     RigidFake.gameObject.SetActive(true);
     bindSkill = GetComponentInChildren <SkillBase>();
     if (bindSkill)
     {
         bindSkill.Init(master);
         Transform tsf = master.transform.Find("SkillStartPos");
         bindSkill.transform.SetParent(tsf ? tsf : master.BeAtkPoint, false);
     }
 }
Esempio n. 22
0
 void InitSkill()
 {
     if (_inited)
     {
         return;
     }
     _inited   = true;
     Master    = ThirdPersonPlayer.Instance;
     bindSkill = GetComponentInChildren <SkillBase>();
     if (bindSkill)
     {
         bindSkill.Init(Master);
         Transform tsf = Master.transform.Find("SkillStartPos");
         bindSkill.transform.SetParent(tsf ? tsf : Master.BeAtkPoint, false);
         bindSkill.transform.localPosition = Vector3.zero;
         bindSkill.transform.localRotation = Quaternion.identity;
     }
 }
Esempio n. 23
0
    public override InteractiveObj FindNextEnemy()
    {
        InteractiveObj enemy = base.FindNextEnemy();

        if (enemy || !myTeam)
        {
            return(enemy);
        }
        for (int i = 0, length = myTeam.MembersCount; i < length; ++i)
        {
            enemy = myTeam.GetMember(i).CurrentTarget;
            if (enemy)
            {
                return(enemy);
            }
        }
        return(enemy);
    }
    public void Insert(InteractiveObj iObj)
    {
        InventoryItem ii = new InventoryItem();

        ii.item     = iObj.gameObject;
        ii.quantity = 1;
        ii.item.SetActive(false);
        inventoryItems.Add(ii);
        //TODO: MissionMgr

        MissionToken mt = ii.item.GetComponent <MissionToken>();

        if (mt != null)
        {
            Debug.Log("In InventoryMgr.Insert: mt=");
            Debug.Log(mt);
            missionMgr.Add(mt);
        }
    }
Esempio n. 25
0
 protected virtual void Settlement(InteractiveObj target)
 {
     if (!target)
     {
         return;
     }
     if (HitFX)
     {
         EffectPlayer.PlayOnTransform(HitFX, target.BeAtkPoint);
     }
     if (HitSE)
     {
         AudioSystem.Instance.PlayAtPos(HitSE, target.BeAtkPoint.position);
     }
     SkillEffectBase[] effects = GetComponentsInChildren <SkillEffectBase>(true);
     for (int i = 0, length = effects.Length; i < length; ++i)
     {
         effects[i].Execute(Master, target);
     }
 }
Esempio n. 26
0
    void OnTrigger(Collider other)
    {
        if (!BattleManager.Instance.IsBattleBegin)
        {
            return;
        }
        switch (objType)
        {
        case Type.Skill:
            InteractiveObj target = other.GetComponent <InteractiveObj>();
            if (!target || target == ThirdPersonPlayer.Instance || !target.IsEnemy(ThirdPersonPlayer.Instance.Camp))
            {
                return;
            }
            SkillEffectBase[] skillEffects = GetComponentsInChildren <SkillEffectBase>(true);
            for (int i = 0, length = skillEffects.Length; i < length; ++i)
            {
                skillEffects[i].Execute(WorldInteractObj.Instance, target);
            }
            UseObj();
            break;

        case Type.TriggerPoint:
            Q_SceneObj obj = other.GetComponent <Q_SceneObj>();
            if (obj && obj.objType == Type.PickUpItem)
            {
                UseObj();
            }
            break;

        case Type.PickUpItem:
            Rigidbody body = GetComponent <Rigidbody>();
            if (body && body.velocity.sqrMagnitude > 0.9f)
            {
                UseObj();
            }
            break;
        }
    }
Esempio n. 27
0
    public void AttackTarget(InteractiveObj tar)
    {
        float lastDistance  = 0;
        float currentOffset = 0;

        for (int i = 0, length = MembersCount; i < length; ++i)
        {
            Character c = listMembers[i];
            if (!c.IsAlive)
            {
                continue;
            }
            float minRange = c.AttackMinRange;
            if (lastDistance == minRange)
            {
                ++currentOffset;
            }
            lastDistance = minRange;
            c.AttackTarget(tar, currentOffset * 3);
        }
        OnAttackTarget.Invoke(tar);
    }
Esempio n. 28
0
    void ThrowItem(InteractiveObj self)
    {
        if (!objPickedItem)
        {
            Debug.LogError("没有可投掷的物体!");
            return;
        }
        Rigidbody rigid          = objPickedItem.GetComponent <Rigidbody>();
        Vector3   localPos       = transform.localPosition;
        Transform tsfSceneCamera = ThirdPersonPlayer.Instance.CameraController.transform;

        rigid.transform.parent = null;
        rigid.constraints      = RigidbodyConstraints.None;
        rigid.gameObject.SetLayer(LayerMask.NameToLayer("Accessable"));
        Vector3 forward = tsfSceneCamera.forward;

        forward.y = 0;
        rigid.AddForce(forward * fThrowPower, ForceMode.VelocityChange);
        objPickedItem = null;
        //ikCtrl.isIkActive = false;
        //ikCtrl.targetObj = null;
    }
Esempio n. 29
0
    void GetInput()
    {
        //입력 받았을 때
        if (!Input.GetKeyDown(PlayerActionKeys.Interact))
        {
            return;
        }

        //이미 열려있는 상자가 있으면
        if (curObj)
        {
            //그 상자 닫고 함수 종료
            curObj = curObj.Interact();
            return;
        }

        //열려있지 않은 상자들을 거리순으로 정렬
        var chestsByDist =
            from chest in interactiveObjs
            where Vector2.Distance(chest.transform.position, player.position) < chestRange
            where chest.isInteractive
            orderby Vector2.Distance(chest.transform.position, player.position)
            select chest;

        //가장 가까운 상자가
        InteractiveObj closest = chestsByDist.DefaultIfEmpty().First();

        //존재하면
        if (closest != null)
        {
            if (curObj)
            {
                Debug.Log(curObj.name);
            }
            //열린상자 갱신하고 엶
            curObj = closest.Interact();
        }
    }
Esempio n. 30
0
    protected override CastResult OnCast()
    {
        for (int i = 0, length = Random.Range(MissleMinCount, MissleMaxCount + 1); i < length; ++i)
        {
            if (ReleaseFX)
            {
                EffectPlayer.PlayOnTransform(ReleaseFX, ReleaseFXPoint);
            }
            if (ReleaseSE)
            {
                AudioSystem.Instance.PlayOnTransform(ReleaseSE, ReleaseFXPoint);
            }
            Missle missle = Instantiate(MisslePrefab, transform.position, transform.rotation).GetOrAddComponent <Missle>();
            switch (LockType)
            {
            case SkillLockType.Position:
                switch (MissleType)
                {
                case Type.Bullet:
                    missle.InitBullet(TargetPos, MissileSpeed, Settlement);
                    break;

                default:
                    missle.Init(TargetPos, MissileSpeed, Settlement);
                    break;
                }
                break;

            case SkillLockType.NoLock:
                switch (MissleType)
                {
                case Type.Bullet:
                    //missle.InitBullet(TargetPos, MissileSpeed, Settlement);
                    break;

                default:
                    missle.gameObject.AddComponent <SphereCollider>().isTrigger = true;
                    missle.gameObject.AddComponent <Rigidbody>().isKinematic    = true;
                    missle.InitFlyFront(Master.transform.forward, MissileSpeed, SkillMaxRange, (hitObj, missleScript) =>
                    {
                        if (hitObj)
                        {
                            InteractiveObj target = hitObj.GetComponent <InteractiveObj>();
                            if (target)
                            {
                                if (target.IsAlive && target.IsEnemy(Master.Camp))
                                {
                                    Settlement(target);
                                    Destroy(missleScript.gameObject);
                                }
                                return;
                            }
                            Q_SceneObj sceneObj = hitObj.GetComponent <Q_SceneObj>();
                            if (sceneObj)
                            {
                                switch (sceneObj.objType)
                                {
                                case Q_SceneObj.Type.Skill:
                                case Q_SceneObj.Type.Item:
                                case Q_SceneObj.Type.NeedItem:
                                    break;

                                default:
                                    return;
                                }
                            }
                        }
                        if (HitFX)
                        {
                            EffectPlayer.PlayAtPos(HitFX, missleScript.transform.position);
                        }
                        if (HitSE)
                        {
                            AudioSystem.Instance.PlayAtPos(HitSE, missleScript.transform.position);
                        }
                        missleScript.Alive = false;
                        Destroy(missleScript.gameObject);
                    });
                    break;
                }
                break;

            default:
                if (Target)
                {
                    missle.Init(Target.transform, MissileSpeed, (tsf) => Settlement(tsf.GetComponent <InteractiveObj>()));
                }
                else
                {
                    missle.Init(TargetPos, MissileSpeed, Settlement);
                }
                break;
            }
            missle.SetLifeTime(MissleLifeTime);
            if (FlySE)
            {
                AudioSystem.Instance.PlayOnTransform(FlySE, missle.transform);
            }
        }
        return(CastResult.Success);
    }
Esempio n. 31
0
 public void Init(InteractiveObj master)
 {
     Master  = master;
     Current = MaxValue > 0 ? Mathf.Min(StartValue, MaxValue) : StartValue;
 }
Esempio n. 32
0
 protected override void OnExecute(InteractiveObj self, InteractiveObj target)
 {
     DoShake(target.BeAtkPoint.position);
 }
Esempio n. 33
0
    void Insert(InteractiveObj iObj)
    {
        // slot into first available slot.
        ObjectInteraction oi = iObj.OnCloseEnough;

        InventoryItem ii = new InventoryItem();
        ii.item = iObj.gameObject;
        ii.quantity = 1;
        ii.displayTexture = oi._texture;
        ii.item.SetActive(false);
        inventoryObjects.Add (ii);

        // update mission manager
        MissionToken mt = ii.item.GetComponent<MissionToken>();
        if (mt!=null) {
            _missionManager.add(mt);
        }

        // if there is a popinfo, instantiate it on pick up.
        Instantiate (ii.item.GetComponent<CustomGameObj>().popUpInfo, Vector3.zero, Quaternion.identity);
    }