public unsafe static void Warp(this ICharacterController obj, ref OpenTK.Vector3 origin)
 {
     fixed(OpenTK.Vector3 *originPtr = &origin)
     {
         obj.Warp(ref *(BulletSharp.Math.Vector3 *)originPtr);
     }
 }
Ejemplo n.º 2
0
        private IAction SendActionsAndWaitForResponse(
            IInitiativeActor activeEntity,
            ICharacterController activeController,
            IReadOnlyDictionary <uint, IAction> availableActions)
        {
            IAction selectedAction;

            do
            {
                // Send Actions to Controller
                _pendingSelectedActionId = null;
                activeController.SelectAction(activeEntity, availableActions, OnActionSelected);

                // Wait for Controller response
                do
                {
                    Thread.Sleep(ACTION_REQUEST_SLEEP_TIME);
                } while (!_pendingSelectedActionId.HasValue);

                // Validate response
                availableActions.TryGetValue(_pendingSelectedActionId.Value, out selectedAction);

                _pendingSelectedActionId = null;
            } while (selectedAction == null || !selectedAction.Available);

            return(selectedAction);
        }
 public unsafe static void SetWalkDirection(this ICharacterController obj, ref OpenTK.Vector3 walkDirection)
 {
     fixed(OpenTK.Vector3 *walkDirectionPtr = &walkDirection)
     {
         obj.SetWalkDirection(ref *(BulletSharp.Math.Vector3 *)walkDirectionPtr);
     }
 }
Ejemplo n.º 4
0
    private ESelection currentSelect;               //現在選択中のボタン

    private void Start()
    {
        controller    = GameManager.Instance.GetController();
        currentSelect = ESelection.StageSelect;

        InitButton();                               //ボタンの初期化
    }
 public unsafe static void SetVelocityForTimeInterval(this ICharacterController obj, ref OpenTK.Vector3 velocity, float timeInterval)
 {
     fixed(OpenTK.Vector3 *velocityPtr = &velocity)
     {
         obj.SetVelocityForTimeInterval(ref *(BulletSharp.Math.Vector3 *)velocityPtr, timeInterval);
     }
 }
Ejemplo n.º 6
0
    void Start()
    {
        panel      = GetComponent <PanelRefAlpha>();
        controller = GameManager.Instance.GetController();

        timer = new Timer(waitTime);
    }
Ejemplo n.º 7
0
 void Start()
 {
     input     = GameManager.Instance.GetController();
     aliveFlag = GetComponent <AliveFlag>();
     timer     = new Timer(2.0f);
     Initialize();
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Use this for initialization
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            if (_Anchor != null && this.enabled)
            {
                ICharacterController lController = InterfaceHelper.GetComponent <ICharacterController>(_Anchor.gameObject);
                if (lController == null)
                {
                    IBaseCameraAnchor lAnchor = _Anchor.GetComponent <IBaseCameraAnchor>();
                    if (lAnchor != null)
                    {
                        IsInternalUpdateEnabled         = false;
                        IsFixedUpdateEnabled            = false;
                        lAnchor.OnAnchorPostLateUpdate += OnControllerLateUpdate;
                    }
                    else
                    {
                        IsInternalUpdateEnabled = true;
                    }
                }
                else
                {
                    IsInternalUpdateEnabled = false;
                    IsFixedUpdateEnabled    = false;
                    lController.OnControllerPostLateUpdate += OnControllerLateUpdate;
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Use this for initialization
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            if (_Anchor != null && this.enabled)
            {
                ICharacterController lController = InterfaceHelper.GetComponent <ICharacterController>(_Anchor.gameObject);
                if (lController != null)
                {
                    IsInternalUpdateEnabled = false;
                    IsFixedUpdateEnabled    = false;
                    lController.OnControllerPostLateUpdate += OnControllerLateUpdate;
                }

                mTilt = QuaternionExt.FromToRotation(_Transform.up, _Anchor.up);

                mToCameraDirection   = _Transform.position - _Anchor.position;
                mToCameraDirection.y = 0f;
                mToCameraDirection.Normalize();

                if (mToCameraDirection.sqrMagnitude == 0f)
                {
                    mToCameraDirection = -_Anchor.forward;
                }
            }

            // Object that will provide access to the keyboard, mouse, etc
            if (_InputSourceOwner != null)
            {
                mInputSource = InterfaceHelper.GetComponent <IInputSource>(_InputSourceOwner);
            }

            // Default the speed we'll use to rotate
            mDegreesPer60FPSTick = _RotationSpeed / 60f;
        }
Ejemplo n.º 10
0
    public void LoadResources()
    {
        characters = new ICharacterController[6];
        GameObject river = Instantiate(Resources.Load("Prefabs/River", typeof(GameObject)), new Vector3(0, -0.25f, 0), Quaternion.identity, null) as GameObject;

        river.name = "river";

        boat      = new BoatController();
        leftLand  = new LandController(-1);
        rightLand = new LandController(1);

        for (int i = 0; i < 3; ++i)
        {
            ICharacterController priest = new ICharacterController(0, "priest" + i);
            priest.setPosition(rightLand.getEmptyPosition());
            priest.getOnLand(rightLand);
            rightLand.getOnLand(priest);
            characters[i] = priest;
        }

        for (int i = 0; i < 3; ++i)
        {
            ICharacterController devil = new ICharacterController(1, "devil" + i);
            devil.setPosition(rightLand.getEmptyPosition());
            devil.getOnLand(rightLand);
            rightLand.getOnLand(devil);
            characters[i + 3] = devil;
        }
    }
        private void CreateCharacter(ControllerType type, Vector2Int position, string characterName, Material material)
        {
            if (type == ControllerType.None)
            {
                return;
            }

            ICharacterController controller = null;

            switch (type)
            {
            case ControllerType.PlayerZQSD:
                controller = new PlayerCharacterController();
                break;

            case ControllerType.PlayerKeypad:
                controller = new Player2CharacterController();
                break;

            case ControllerType.RandomAI:
                controller = new RandomCharacterController();
                break;

            case ControllerType.MCTSAI:
                controller = new MCTSCharacterController();
                break;
            }

            CharacterScript character = Instantiate(_characterPrefab, new Vector3(position.x, 0, position.y), Quaternion.identity, Map.transform).GetComponent <CharacterScript>();

            character.Initialize(controller, material, characterName);
            Characters.Add(character);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Called when the component is enabled. This is also called after awake. So,
 /// we need to ensure we're not doubling up on the assignment.
 /// </summary>
 protected void OnEnable()
 {
     if (_Anchor != null)
     {
         ICharacterController lController = InterfaceHelper.GetComponent <ICharacterController>(_Anchor.gameObject);
         if (lController != null)
         {
             if (lController.OnControllerPostLateUpdate != null)
             {
                 lController.OnControllerPostLateUpdate -= OnControllerLateUpdate;
             }
             lController.OnControllerPostLateUpdate += OnControllerLateUpdate;
         }
         else
         {
             IBaseCameraAnchor lAnchor = _Anchor.GetComponent <IBaseCameraAnchor>();
             if (lAnchor != null)
             {
                 if (lAnchor.OnAnchorPostLateUpdate != null)
                 {
                     lAnchor.OnAnchorPostLateUpdate -= OnControllerLateUpdate;
                 }
                 lAnchor.OnAnchorPostLateUpdate += OnControllerLateUpdate;
             }
         }
     }
 }
Ejemplo n.º 13
0
    protected ICharacterController ProbeCharacterController()
    {
        ICharacterController conn = null;

        switch (m_controllerType)
        {
        case ControllerType.KEYBOARD:
            conn = GetComponent <ManualKeyboardController>();
            break;

        case ControllerType.AI_WALKER:
            conn = GetComponent <AI_Walker>();
            break;

        case ControllerType.AI_BERSERKER:
            conn = GetComponent <AI_Berserker>();
            break;

        default:
            Debug.LogError("Invalid controller type!", this);
            break;
        }

        if (conn == null)
        {
            Debug.LogError("Cannot find proper controller attached to object!", this);
        }

        return(conn);
    }
Ejemplo n.º 14
0
        public void Execute(ICharacterController pc, PlayerInput input)
        {
            // TODO fixx
//            if( string.IsNullOrWhiteSpace( ( ( PlayerController )pc ).LastTellFrom ) )
//            {
//                pc.View.Write( "You have noone to reply to.\n" );
//                return;
//            }
//
//            if( string.IsNullOrWhiteSpace( input.RawArguments ) )
//            {
//                pc.View.WriteFormat( "Tell {0} what?\n", ( ( PlayerController )pc ).LastTellFrom );
//                return;
//            }
//
//            var vpc = ( PlayerController )( World.ActivePlayers.Find(
//                player => player.Model.ShortDescr == ( ( PlayerController )pc ).LastTellFrom ) );
//
//            if( vpc == null )
//            {
//                pc.View.Write( "You do not see any player by this name.\n" );
//                return;
//            }
//
//            pc.View.WriteFormat( "You tell {0} '{1}'.\n", vpc.Model.ShortDescr, input.RawArguments );
//            vpc.View.WriteFormat( "{0} tells you '{1}'.\n", pc.Model.ShortDescr, input.RawArguments );
//            vpc.LastTellFrom = pc.Model.ShortDescr;
        }
Ejemplo n.º 15
0
    public void LoadResources()
    {
        GameObject water = Instantiate(Resources.Load("Prefabs/water", typeof(GameObject))) as GameObject;

        fromCoast = new CoastController(0, new Vector3(0, 0, 0));
        toCoast   = new CoastController(1, new Vector3(12, 0, 0));
        boat      = new BoatController();

        characters = new ICharacterController[6];
        for (int i = 0; i < 3; i++)
        {
            characters[i] = new ICharacterController(i, "priest", new Vector3((float)2.5 - i, (float)1.25, 0));
        }
        for (int i = 3; i < 6; i++)
        {
            characters[i] = new ICharacterController(i, "devil", new Vector3((float)2.5 - i, (float)1.25, 0));
        }
        fromCoast.initStorage(characters);

        /*
         * Debug.Log("check whether:" + (fromCoast.storage.characterStorage[0] == fromCoast.storage.characterStorage[1]));
         * for(int i=0;i<6;i++)
         * {
         *  Debug.Log(fromCoast.storage.characterStorage[i].character.name);
         * }*/
    }
Ejemplo n.º 16
0
    public void genGameObjects()
    {
        characters = new ICharacterController[6];
        boat       = new BoatController();
        leftLand   = new LandController(-1);
        rightLand  = new LandController(1);

        for (int i = 0; i < 3; i++)
        {
            ICharacterController priest = new ICharacterController(0, "priest" + i);
            priest.setPosition(rightLand.getEmptyPosition());
            priest.getOnLand(rightLand);
            rightLand.getOnLand(priest);
            characters[i] = priest;
        }

        for (int i = 0; i < 3; i++)
        {
            ICharacterController demon = new ICharacterController(1, "demon" + i);
            demon.setPosition(rightLand.getEmptyPosition());
            demon.getOnLand(rightLand);
            rightLand.getOnLand(demon);
            characters[i + 3] = demon;
        }
    }
Ejemplo n.º 17
0
        public void Execute(ICharacterController pc, PlayerInput input)
        {
            // TODO fix
//            if( input.Arguments.Count() == 0 )
//            {
//                pc.View.Write( "Tell whom what?\n" );
//                return;
//            }
//
//            var vpc = ( PlayerController )( World.ActivePlayers.Find(
//                player => player.Model.ShortDescr.StartsWith( input.Arguments.ElementAt( 0 ), StringComparison.CurrentCultureIgnoreCase ) ) );
//
//            if( vpc == null )
//            {
//                pc.View.Write( "You do not see any player by this name.\n" );
//                return;
//            }
//
//            if( input.Arguments.Count() < 2 )
//            {
//                pc.View.WriteFormat( "Tell {0} what?\n", vpc.Model.ShortDescr );
//                return;
//            }
//
//            pc.View.WriteFormat( "You tell {0} '{1}'.\n", vpc.Model.ShortDescr, string.Join( " ", input.Arguments.Skip( 1 ) ) );
//            vpc.View.WriteFormat( "{0} tells you '{1}'.\n", pc.Model.ShortDescr, string.Join( " ", input.Arguments.Skip( 1 ) ) );
//            vpc.LastTellFrom = pc.Model.ShortDescr;
        }
Ejemplo n.º 18
0
        public CharacterViewTest()
        {
            _characterController = Substitute.For <ICharacterController>();

            var characters = new List <Character>
            {
                new Character {
                    Name = "Sally"
                }, new Character {
                    Name = "Rick"
                },
                new Character {
                    Name = "Joe"
                }
            };

            _characterController.GetCharacterData().Returns(characters);
            var user = new User
            {
                Email = "*****@*****.**"
            };

            _characterController.User.Returns(user);

            _characterController.When(x => x.Delete("Sally"))
            .Do(info => characters.Remove(characters.First(x => x.Name == "Sally")));

            _console      = Substitute.For <IConsoleWrapper>();
            _newCharacter = Substitute.For <INewCharacterView>();
            _mainView     = Substitute.For <IMainView>();
            _sut          = new CharacterView(_console, _characterController, _mainView, _newCharacter);
        }
Ejemplo n.º 19
0
 public CharacterOnGameLoop(ICharacterController character, IObserver observer,
                            FuncActionDispatcher funcActionDispatcher) :
     base(funcActionDispatcher)
 {
     m_character = character;
     m_observer  = observer;
 }
Ejemplo n.º 20
0
 private void PerformAction(ICharacterController _controller, List <InputActions> _actionsToPerform)
 {
     foreach (InputActions _action in _actionsToPerform)
     {
         _action.Execute(_controller);
     }
 }
Ejemplo n.º 21
0
 protected virtual void Start()
 {
     stateMachine     = GetComponentInChildren <Animator>();
     skeletonAnimator = GetComponentInChildren <SkeletonAnimator>();
     viewResetPos     = skeletonAnimator.transform.localPosition; //Store this for ResetView()
     LinkToStateBehaviors();
     controller = controllerContainer.Result;                     //Make controller linkable in the editor, still accessible as an interface.
 }
Ejemplo n.º 22
0
 public Party(Battlefield battlefield, ICharacterController characterController, int amountToCreate)
 {
     for (int i = 0; i < amountToCreate; i++)
     {
         CharacterType randomType = Helpers.GetRandomElement(AllowedCharacterTypes);
         CreateNewCharacter(randomType, characterController, battlefield);
     }
 }
    private GameObject reflectParent;               //像の親オブジェクト

    void Start()
    {
        controller    = GameManager.Instance.GetController();
        usedMirrors   = new Queue();
        reflectParent = new GameObject("Reflects");

        currentMirror = 0;
    }
Ejemplo n.º 24
0
 public IEnumerable <IAction> TakeTurn(
     IInitiativeActor activeActor,
     ICharacterController actorController,
     IReadOnlyCollection <ITargetableActor> allTargets,
     IStandardActionGenerator standardActionGenerator)
 {
     yield break;
 }
Ejemplo n.º 25
0
 public void Execute(ICharacterController pc, PlayerInput input)
 {
     // TODO: train-wreck
     pc.Model.Event("ch_said_text",
                    EventReturnMethod.None,
                    new EventArg("ch", pc.Model),
                    new EventArg("text", input.RawArguments));
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Gives us an opportunity to modify the AC's movement prior to having it applied
 /// </summary>
 /// <param name="rController"></param>
 /// <param name="rFinalPosition"></param>
 /// <param name="rFinalRotation"></param>
 protected void OnControllerMoved(ICharacterController rController, ref Vector3 rFinalPosition, ref Quaternion rFinalRotation)
 {
     if (_MovementFactor != 1f)
     {
         Vector3 lMovement = rFinalPosition - mActorController._Transform.position;
         rFinalPosition = mActorController._Transform.position + (lMovement.normalized * (lMovement.magnitude * _MovementFactor));
     }
 }
Ejemplo n.º 27
0
    public void clickCharacter(ICharacterController charctrl)
    {
        //legal check
        if ((charctrl.place == "from" && boat.boatStatus == 1) || (charctrl.place == "to" && boat.boatStatus == 0))
        {
            return;
        }
        if (userInterface.status != 0)
        {
            return;
        }
        if (boat.boatFull() && charctrl.onBoat == false)
        {
            return;
        }

        //Debug.Log(charctrl.character.name);
        CoastController whichCoast;

        if (boat.boatStatus == 0)
        {
            whichCoast = fromCoast;
        }
        else
        {
            whichCoast = toCoast;
        }
        //Debug.Log("check coastcontroller " + whichCoast.coast.name);
        //Debug.Log("check boatcontroller " + boat.boat.name);

        //检查是否合法

        //备注:上船与下船不对称,上船时船负责提供运动终点,下船时岸负责提供运动终点
        if (charctrl.onBoat == false)//上船的过程
        {
            // Debug.Log("function clickCharacter ready to go on boat with parameter:" + charctrl.character.name);
            whichCoast.OffCoast(charctrl);//离岸
            boat.OnBoat(charctrl);
        }
        else
        {
            // Debug.Log("function clickCharacter ready to go off boat with parameter:" + charctrl.character.name);
            whichCoast.OnCoast(charctrl, boat.boatStatus);//下船上岸
            boat.OffBoat(charctrl);
        }

        int flag = checkGameOver();

        Debug.Log("check game over:" + flag);
        if (flag == 1)
        {
            userInterface.status = 2;
        }
        else if (flag == -1)
        {
            userInterface.status = 1;
        }
    }
Ejemplo n.º 28
0
Archivo: Go.cs Proyecto: kaerber/kmud
        public override void Execute( ICharacterController pc, PlayerInput input ) {
            if( !string.IsNullOrWhiteSpace( _direction ) ) {
                input.Arguments = new List<string> { _direction };
                base.Execute( pc, input );
                return;
            }

            base.Execute( pc, input );
        }
        public override void SpawnPlayerUI(ICharacterController _currentPlayerControllerInstance)
        {
            scoreViewInstance = GameObject.Instantiate(scoreViewPrefab, currentViewPos, Quaternion.identity);
            scoreViewInstance.gameObject.transform.SetParent(parentLayoutGroup.transform);
            currentViewPos += new Vector3(0, -5f, 0);

            scoreViewInstance.SetPlayerController(_currentPlayerControllerInstance);
            listOfScoreView.Add(scoreViewInstance);
        }
Ejemplo n.º 30
0
        public Party(Battlefield battlefield, ICharacterController characterController, int allies)
        {
            CreateCharacterInstances(allies);

            foreach (Character characterToInitialize in Characters)
            {
                characterToInitialize.Initialize(battlefield, characterController);
            }
        }
Ejemplo n.º 31
0
        public Matrix GetCharacterControllerView(ICharacterController controller)
        {
            // Get the controlled object (the CollidableEntity) from the controller.
            ICollisionObject obj = controller.ParentObject;

            // Need the direction it's facing and the world bounds.
            Vector3 forward = Vector3.Normalize(obj.World.Forward);
            BoundingBox worldbox = obj.WorldBoundingBox;

            // Calculate the eye location for the object.
            Vector3 eyelocation = Vector3.Zero;
            eyelocation.X = (worldbox.Max.X + worldbox.Min.X) * 0.5f;
            eyelocation.Z = (worldbox.Max.Z + worldbox.Min.Z) * 0.5f;
            eyelocation.Y = (worldbox.Max.Y - worldbox.Min.Y) * 0.9f + worldbox.Min.Y;

            // Convert it to a view matrix.
            return Matrix.Invert(Matrix.CreateRotationX(_CharacterLookUpDownAngle) * Matrix.CreateWorld(eyelocation, forward, Vector3.Up));
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Callback for when the controller moves or rotates. We'll use this to help rotate the inner sphere
        /// </summary>
        /// <param name="rController">The actor controller this driver is associated with</param>
        /// <param name="rNewPosition">Position the actor will be moved to</param>
        /// <param name="rNewRotation">Rotation the actor will be turned to</param>
        private void OnControllerMoved(ICharacterController rController, ref Vector3 rNewPosition, ref Quaternion rNewRotation)
        {
            // We don't want platform movement to effect our sphere
            Vector3 lNewPosition = rNewPosition - mActorController.State.MovementPlatformAdjust;

            // We'll apply the platform rotation to our sphere
            Quaternion lPlatformRotation = mActorController.State.RotationPlatformAdjust;

            // Figure out the roll based on the movement
            Vector3 lLocalMove = transform.InverseTransformPoint(lNewPosition);
            Vector3 lLocalRotation = new Vector3(lLocalMove.z, 0f, -lLocalMove.x) * mAnglePerUnit;

            Quaternion lRotation = Quaternion.Euler(transform.rotation * lLocalRotation);
            mRoll = lPlatformRotation * lRotation * mRoll;

            // Just keep resetting the roll we had even if there was no change. This will keep
            // the sphere from rotating as we rotate the actor.
            mSphere.rotation = mRoll;
        }
Ejemplo n.º 33
0
 /// <summary>
 /// Delegate callback for handling the camera movement AFTER the character controller
 /// </summary>
 /// <param name="rController"></param>
 /// <param name="rDeltaTime"></param>
 /// <param name="rUpdateIndex"></param>
 private void OnControllerLateUpdate(ICharacterController rController, float rDeltaTime, int rUpdateIndex)
 {
     RigLateUpdate(rDeltaTime, rUpdateIndex);
 }
Ejemplo n.º 34
0
        public void HandleCharacterControllerInput(GameTime gametime, ICharacterController controller)
        {
            float timescale = (float)gametime.ElapsedGameTime.TotalSeconds;
            float rotatescale = 1.5f;

            // Avoid moving with keyboard and mouse when the editor is open.
            if (controller.PlayerNumber == 0 && SunBurnEditorClient.Instance.EditorOpen)
                return;

            // Apply player input.
            controller.Move(new Vector2(_InputSources.MoveAmount.X, 0.0f));
            controller.Move(new Vector2(0.0f, _InputSources.MoveAmount.Y));
            controller.Turn(-_InputSources.TurnAmount * rotatescale);

            if (_InputSources.Jump)
                controller.Jump();

            controller.Crouch = _InputSources.Crouch;

            // Apply up / down view.
            _CharacterLookUpDownAngle += _InputSources.LookUpDownAmount * rotatescale * timescale;

            // Clamp the look up / down range.
            _CharacterLookUpDownAngle = MathHelper.Clamp(_CharacterLookUpDownAngle, -1.0f, 1.0f);
        }