Ejemplo n.º 1
0
        private void FixedUpdate()
        {
            if (!_Actor)
            {
                return;
            }
            else
            {
                _Actor._position = transform.position;

                Vector2 _mouse = new Vector2(
                    Input.GetAxisRaw("Mouse X"),
                    Input.GetAxisRaw("Mouse Y")
                    );

                Quaternion R = LookRotate(
                    _View.rotation,
                    _mouse,
                    _MaxVerticalViewAngle
                    );

                _View.rotation = R;

                Cursor.lockState = CursorLockMode.Locked;

                Vector2 _input =
                    new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));

                Vector3 _wishvel = _View.rotation * new Vector3(_input[0], 0, _input[1]);
                _wishvel = Vector3.ClampMagnitude(_wishvel, 1.0F);

                if (_Actor.Ground.stable)
                {
                    Vector3 _rit = Vector3.Cross(_wishvel, _Actor._orientation * new Vector3(0, 1, 0));
                    _rit.Normalize();

                    Vector3 _fwd = Vector3.Cross(_Actor.Ground.normal, _rit);
                    _fwd.Normalize();

                    _wishvel = _fwd * (_wishvel.magnitude);

                    _Actor.SetVelocity(_wishvel * _MaxMovementSpeed);
                }
                else
                {
                    _Actor.SetVelocity(_Actor._velocity - Vector3.up * GlobalTime.FDT * 39.62F);
                }

                if (_Actor.Ground.stable && Input.GetAxis("Fire1") > 0)
                {
                    _Actor.SetSnapEnabled(false);
                    _Actor.SetVelocity(_Actor._velocity + Vector3.up * 10F);
                }

                ActorHeader.Move(this, _Actor, GlobalTime.FDT);

                transform.position = _Actor._position;
            }
        }
Ejemplo n.º 2
0
    public override void Simulate(EnemyArgs _args)
    {
        ActorHeader.Actor     _actor = _args.Actor;
        UnityEngine.Transform _self  = _args.Self;

        _actor.SetPosition(_self.position);
        _actor.SetOrientation(_self.rotation);

        ActorHeader.Move(this, _actor, GlobalTime.FDT);

        _self.SetPositionAndRotation(_actor._position, _actor._orientation);
    }
Ejemplo n.º 3
0
    public override void Simulate(ActorArgs _args)
    {
        ActorHeader.Actor     Actor     = _args.Actor;
        UnityEngine.Transform Transform = _args.ActorTransform;

        Actor.SetPosition(Transform.position);
        Actor.SetOrientation(Transform.rotation);

        ActorHeader.Move(this, Actor, GlobalTime.FDT);

        Transform.SetPositionAndRotation(Actor._position, Actor._orientation);

        return;
    }
Ejemplo n.º 4
0
    public void OnFixedUpdate()
    {
        float fdt = Time.fixedDeltaTime;

        // for loop begin
        for (int i = 0; i < actors.Count; i++)
        {
            // get transform component on gameobject
            // and assign its contents to actor

            Actor     a = actors[i];
            Transform t = a.transform;

            a.SetPosition(t.position);
            a.SetOrientation(t.rotation);
        }

        // for loop move
        for (int i = 0; i < actors.Count; i++)
        {
            // move
            ActorHeader.Move(this, actors[i], fdt);
        }

        // for loop end

        for (int i = 0; i < actors.Count; i++)
        {
            // get newly calculated position and rotation
            // assign to transform
            Actor     a = actors[i];
            Transform t = a.transform;

            t.SetPositionAndRotation(a.position, a.orientation);
        }
    }
Ejemplo n.º 5
0
        private void Start()
        {
            _actor = GetComponent <ActorHeader.Actor>();
            _actor.SetMoveType(ActorHeader.MoveType.Slide);
            _actor.SetSnapType(ActorHeader.SlideSnapType.Toggled);
            _actor.SetSnapEnabled(true);

            // update actor state to transform state
            _actions.Add((_actor) =>
            {
                CommandHeader.ApplyActorTransform(transform, _actor);
                return(true);
            });

            // gravity
            _actions.Add((_actor) =>
            {
                if (!_actor.Ground.stable)
                {
                    _actor._velocity -= Vector3.up * 39.62F * GlobalTime.FDT;
                }
                return(true);
            });

            // bounce determinism
            _actions.Add((_actor) =>
            {
                if (_bouncecount <= 0)
                {
                    _actor.SetVelocity(Vector3.zero);
                    _actor.SetSnapEnabled(false);
                    return(false);
                }
                else
                {
                    if (_actor.Ground.stable)
                    {
                        _bouncecount--;
                        _actor.SetSnapEnabled(false);
                        _actor.SetVelocity(_actor.Ground.normal * (_bouncecount));
                    }

                    return(true);
                }
            });

            // snap detection procedure
            _actions.Add((_actor) =>
            {
                if (_bouncecount <= 0)
                {
                    return(false);
                }
                else
                {
                    // wait at least two frames until we determine eligiblity to snap again.
                    if (!_actor.Ground.stable && !_actor.LastGround.stable)
                    {
                        _actor.SetSnapEnabled(true);
                    }
                    return(true);
                }
            });

            // move procedure
            _actions.Add((_actor) =>
            {
                if (_bouncecount <= 0)
                {
                    return(false);
                }
                else
                {
                    ActorHeader.Move(this, _actor, GlobalTime.FDT);
                    return(true);
                }
            });

            // update transform state to actor state
            _actions.Add((_actor) =>
            {
                CommandHeader.ApplyTransformActor(transform, _actor);
                return(true);
            });
        }
Ejemplo n.º 6
0
 /* At the moment, CharacterActor placement inside of the ActorSystem will determine who has authority in
  *  pushing others. This isn't good if one is attempting to manage server-side movement. However, you can
  *  get away from this by simply storing your actors in a SortedList<> rather than a List and iterating that way.
  *  You can use player ID or Client IDs to arbitrarily choose who moves first. It's stupid, I know. I'm not an
  *  expert in resolving these types of cases...
  *
  *  We need to send our actor data to the transform so later entities can find the correct positional data during
  *  their traces/overlaps
  */
 public void MoveFrame(float fdt)
 {
     ActorHeader.Move(this, Actor, fdt);
     transform.SetPositionAndRotation(Actor.position, Actor.orientation);
 }