예제 #1
0
    public void Awake()
    {
        _characterComponent = GetComponent <CharacterComponent>();
        _network            = GetComponent <NetworkOwnershipComponent>();

        _viewRPC = FindReplicationViewForComponent <CharacterTargetingComponent>();
    }
예제 #2
0
    public AutoAttackModel StartChargeAttack(GameObject target, ChargeAttackInputHandler inputHandler)
    {
        ReplicationView view = target.GetComponent <ReplicationView>();

        StartChargeAttackRPC(view.viewId);
        _viewRPC.RPC("StartChargeAttackRPC", EB.RPCMode.Others, view.viewId);

        return(_combatController.GetCurrentAttack());
    }
예제 #3
0
    public void Awake()
    {
        _networkLocomotionComponentViewRPC = FindReplicationViewForComponent <NetworkLocomotionComponent>();
        _locomotion    = GetComponent <LocomotionComponentAPP>();
        _rvoController = GetComponent <RVOController>();

        _isCurrentlyLocal = AmILocal();
        _currentOwnerId   = _networkLocomotionComponentViewRPC.ownerId;
    }
예제 #4
0
    void Awake()
    {
        if (_stateHandlers == null)
        {
            _stateHandlers = new Dictionary <eCampaignCharacterState, System.Type>();

            //ToDo:���÷��䵼��������ù�ϵ���ײ鿴
            //Assembly assembly = Assembly.GetAssembly(typeof(CharacterStateHandler));
            //foreach (System.Type t in assembly.GetTypes())
            //{
            //	if (!t.IsAbstract && t.IsSubclassOf(typeof(CharacterStateHandler)))
            //	{
            //		CharacterStateHandlerAttribute attr = (CharacterStateHandlerAttribute)t.GetCustomAttributes(typeof(CharacterStateHandlerAttribute), false)[0];
            //		_stateHandlers.Add(attr.handledState, t);
            //	}
            //}

            var type = typeof(AttackTargetStateHandler);
            _stateHandlers.Add(((CharacterStateHandlerAttribute)type.GetCustomAttributes(typeof(CharacterStateHandlerAttribute), false)[0]).handledState, type);
            type = typeof(ChaseTargetStateHandler);
            _stateHandlers.Add(((CharacterStateHandlerAttribute)type.GetCustomAttributes(typeof(CharacterStateHandlerAttribute), false)[0]).handledState, type);
            type = typeof(IdleStateHandler);
            _stateHandlers.Add(((CharacterStateHandlerAttribute)type.GetCustomAttributes(typeof(CharacterStateHandlerAttribute), false)[0]).handledState, type);
            type = typeof(InteractStateHandler);
            _stateHandlers.Add(((CharacterStateHandlerAttribute)type.GetCustomAttributes(typeof(CharacterStateHandlerAttribute), false)[0]).handledState, type);
            type = typeof(MoveStateHandler);
            _stateHandlers.Add(((CharacterStateHandlerAttribute)type.GetCustomAttributes(typeof(CharacterStateHandlerAttribute), false)[0]).handledState, type);
        }

        _animator = GetComponentInChildren <Animator>();

        _controller = GetComponent <Controller>();
        if (_controller is EnemyController)
        {
            ((EnemyController)_controller).onDestroy += OnEnemyKilled;
        }

        _combatController = GetComponent <CombatController>();
        _viewRPC          = FindReplicationViewForComponent <CharacterComponent>();

        //_effectReceiver = new EffectReceiver(gameObject);

        _conditionComponent = GetComponent <ConditionComponent>();
        _targetingComponent = GetComponent <CharacterTargetingComponent>();
        //_animationController = GetComponent<AnimationController>();

        _moveController = GetComponent <CampaignMoveController>();

        _locomotionComponent = (ILocomotionComponent)GetComponent(typeof(ILocomotionComponent));
        if (_locomotionComponent != null)
        {
            _locomotionComponent.Initialize();
        }
        //_network = GetComponent<NetworkOwnershipComponent>();
    }
예제 #5
0
        private void OnViewIdAllocated(ReplicationView view)
        {
            if (playerController.ViewRPC != view)
            {
                return;
            }

            if (!playerController._isLocalPlayer)
            {
                return;
            }
            mDMono.gameObject.name = (playerController.ViewRPC != null ? "Player" + playerController.ViewRPC.viewId.p : "Player");

            playerController.ReplicationPlayer = playerController.ViewRPC != null ? playerController.ViewRPC.instantiatorPlayer : null;

            _initialPlayerIndex = (Replication.IsLocalGame) ? 0 : playerController.ReplicationPlayer.Index;

            TransferDartMember dartData = AlliancesManager.Instance.TransferDartInfo.GetCurrentDart();

            if (AllianceUtil.IsInTransferDart && dartData != null)
            {
                StartTransfer(dartData.DartName, dartData.TargetNpc, false, true);
            }
            else
            {
                string userid    = LoginManager.Instance.LocalUserId.Value.ToString();
                string classname = UI.BuddyAttributesManager.GetModelClass(userid);
                if (string.IsNullOrEmpty(classname))
                {
                    EB.Debug.LogError("OnViewIdAllocated: classname not found for uid = {0}", userid);
                    return;
                }
                ChangeModel(classname, true);
            }

            if (_initialPlayerIndex == Replication.LocalPlayerIndex)
            {
                EB.Assets.LoadAsync("Bundles/VFX/ReticleFX/Reticle_TargetLocation", typeof(GameObject), o =>
                {
                    if (o)
                    {
                        GameObject go  = GameObject.Instantiate(o as GameObject);
                        _moveReticle   = go.GetComponent <MoveReticleComponent>();
                        _moveReticleFX = _moveReticle.GetComponent <FXPoolable>();
                        _moveReticle.gameObject.CustomSetActive(false);
                        SetInstantiatedParents();
                    }
                });
            }
        }
예제 #6
0
    public void Interact(GameObject player)
    {
        if (Time.time - _lastInteractTimestamp < 0.5f)
        {
            return;
        }

        _lastInteractTimestamp = Time.time;
        InteractFromRPC(player);
        if (!LocalOnly && _viewRPC != null)
        {
            ReplicationView playerView = player.GetComponent <ReplicationView>();
            _viewRPC.RPC("InteractRPC", EB.RPCMode.Others, playerView.viewId);
        }
    }
예제 #7
0
    void Start()
    {
        ReplicationView view = GetComponent <ReplicationView>();

        _owner = view != null ? view.instantiatorPlayer : null;

        _playerTransform = transform;
        Controller c = _playerTransform.GetComponent <Controller>();

        _muzzleTransform = _playerTransform;
        if (c != null && c.SkinnedRigPrefab != null)
        {
            _muzzleTransform = GameUtils.SearchHierarchyForBone(c.SkinnedRigPrefab.transform, "muzzle");
        }
        mRoot = GameObject.FindObjectOfType <UIRoot>();
    }
예제 #8
0
    protected ReplicationView FindReplicationViewForComponent <ComponentType>()
    {
        ReplicationView view = null;

        ReplicationView[] replicationViews = GetComponents <ReplicationView>();

        foreach (ReplicationView replicationView in replicationViews)
        {
            if (replicationView.observed is ComponentType)
            {
                view = replicationView;
                break;
            }
        }

        return(view);
    }
예제 #9
0
    void Start()
    {
        if (_interactable == null)
        {
            _interactable = GetComponent <InteractableComponent>();
        }

        if (_interactable == null)
        {
            EB.Debug.LogError("InteractableStatsComponent: _interactable is null");
        }

        LocalOnly = _interactable.localOnly;
        if (!LocalOnly)
        {
            _viewRPC = FindReplicationViewForComponent <InteractableStatsComponent>();
            if (_viewRPC == null)            // && GameStateManager.HasSparxGame)
            {
                _viewRPC          = gameObject.AddComponent <ReplicationView>();
                _viewRPC.observed = this;
            }
        }
    }
예제 #10
0
    public static PlayerController LocalPlayerController()
    {
        if (_localPlayerController == null)
        {
            if (_localPlayerGameObject != null)
            {
                _localPlayerController = _localPlayerGameObject.GetComponent <PlayerController>();
            }

            for (int i = 0; i < _sPlayerControllers.Count; i++)
            {
                PlayerController pc   = _sPlayerControllers[i];
                ReplicationView  view = pc.gameObject.GetComponent <ReplicationView>();
                if ((view != null && view.instantiatorPlayer == Replication.LocalPlayer) /*|| !GameStateManager.HasSparxGame*/ || Replication.IsLocalGame)
                {
                    _localPlayerController = pc;
                    _localPlayerGameObject = _localPlayerController.gameObject;
                    break;
                }
            }
        }

        return(_localPlayerController);
    }
예제 #11
0
 public void Awake()
 {
     _networkOwnershipComponentViewRPC = FindReplicationViewForComponent <NetworkOwnershipComponent>();
 }
예제 #12
0
 protected void Awake()
 {
     _characterComponent = GetComponent <CharacterComponent>();
     _viewRPC            = FindReplicationViewForComponent <Controller>();
     _targetingComponent = GetComponent <CharacterTargetingComponent>();
 }