Ejemplo n.º 1
0
    protected virtual void HandleMovement(float input)
    {
        float newXVelocity = velocity.x;

        facing = (LookDirections)input;

        if (input != 0)
        {
            newXVelocity = Accelerate(newXVelocity, input);
        }

        //apply deceleration if I'm not pressing anything or if I'm pressing the opposite from where I'm going (turning around)
        if ((input == 0 && Mathf.Abs(newXVelocity) > stopLeeway) || ((input > 0 && newXVelocity < 0) || (input < 0 && newXVelocity > 0)))
        {
            newXVelocity = Decelerate(newXVelocity);
        }
        else if (Mathf.Abs(newXVelocity) <= stopLeeway)
        {
            newXVelocity = 0;
        }

        if (newXVelocity != 0)
        {
            CheckDirections checkDirection = newXVelocity > 0? CheckDirections.right : CheckDirections.left;
            RaycastHit2D[]  hits           = CollisionCheck(Mathf.Abs(newXVelocity * Time.deltaTime), MoveLayers, checkDirection, HitWall);
            //RaycastHit2D[] hits = CollisionCheck(Mathf.Abs(newXVelocity * Time.deltaTime), MoveLayers, CheckDirections.down, HitWall);

            if (hits.Length > 0)
            {
                RaycastHit2D useData = new RaycastHit2D();
                foreach (RaycastHit2D hit in hits)
                {
//					if (IsAWall(hit.normal)){
                    if (hit.fraction > 0)
                    {
                        useData = hit;
                        break;
                    }
                }


                if (useData.fraction > 0 && velocity.x != 0)
                {
                    t.position   = new Vector3(useData.point.x - boxCol.size.x / 2 * (velocity.x > 0? 1 : -1), t.position.y, t.position.z);
                    newXVelocity = 0;
                }
            }
        }


        velocity = new Vector2(newXVelocity, velocity.y);
    }
Ejemplo n.º 2
0
        public void TaskMethod(List <LightSource> lights, List <Triangle> triangles)
        {
            Point  ray    = Point.GeneratePointOnSphere(Origin);
            Vector vector = new Vector(Origin, ray);
            float  a      = Trace(lights, triangles, vector, MaxDept);

            ray.MultiplyByLambda(a);
            if (!LookDirections.Contains(vector.GetEndPoint()))
            {
                lock (lockObj)
                {
                    LookDirections.Add(vector.GetEndPoint());
                }
            }
        }
Ejemplo n.º 3
0
 private void StartSequential(List <LightSource> lights, List <Triangle> triangles)
 {
     for (int i = 0; i < Sampling; i++)
     {
         Point  ray    = Point.GeneratePointOnSphere(Origin);
         Vector vector = new Vector(Origin, ray);
         float  a      = Trace(lights, triangles, vector, MaxDept);
         ray.MultiplyByLambda(a);
         if (!LookDirections.Contains(vector.GetEndPoint()))
         {
             LookDirections.Add(vector.GetEndPoint());
         }
     }
     bs.Close();
 }
Ejemplo n.º 4
0
    private void initialize()
    {
        jump           = GetComponent <Jump>();
        walk           = GetComponent <PlayerWalk>();
        firePivot      = transform.FindChild("FirePivot");
        teleportable   = GetComponent <Teleportable>();
        dieAnim        = GetComponent <PlayerDieAnim>();
        crouch         = GetComponent <Crouch>();
        idle           = GetComponent <Idle>();
        lookDirections = GetComponent <LookDirections>();
        body           = GetComponent <ChipmunkBody>();

        rightFireDir.x = 1f;
        rightFireDir.y = -0.5f;
        leftFireDir.x  = -1f;
        leftFireDir.y  = -0.5f;
        fireDir        = rightFireDir;

        collisionGroupSkip = GetComponent <ChipmunkShape>().collisionGroup;
        // not sure if ok: all layers except Player's layer
        collisionLayersSkip = unchecked ((uint)(1 << KLayers.PLAYER));
        //collisionLayers = 0;
    }
Ejemplo n.º 5
0
 void Start()
 {
     lookDirections  = GetComponent <LookDirections>();
     walkAC_orig     = base.walkAC;
     walkLookingUpAC = AnimateTiledConfig.getByName(gameObject, EnumAnimateTiledName.WalkLookUpwards, true);
 }