public override EnemyState HandleInput(EntityController e, EntityInput i)
    {
        e.CheckFlip(i.horz);
        //Do nothing
        if (Mathf.Abs(i.horz) > 0)
        {
            e.body.AddForce(e.transform.right * Mathf.Sign(i.horz) * e.ACCELX);
            if (Mathf.Abs(e.body.velocity.x) > e.MAXSPEEDX)
            {
                e.body.velocity = new Vector2(e.MAXSPEEDX * Mathf.Sign(e.body.velocity.x), e.body.velocity.y);
            }
        }
        // else
        // {
        //     if(Mathf.Abs(e.body.velocity.x) <= e.SLOWDOWNTHRES && Mathf.Abs(e.body.velocity.x) > e.STOPTHRESH)
        //     {
        //         e.body.AddForce(new Vector2 (Mathf.Sign(e.body.velocity.x), 0) * -e.ACCELSLOWDOWN);
        //     }
        //     else
        //     {
        //         e.Stop();
        //     }
        // }

        return(null);
    }
 public void SwitchToNoControl()
 {
     if (currentPilot != null)
     {
         currentPilot.Disable();
     }
     currentPilot = null;
 }
 public override EnemyState Update(EntityController e, EntityInput i)
 {
     e.anim.SetFloat("walkingSpeed", e.body.velocity.x / e.MAXSPEEDX);
     if (Mathf.Abs(e.body.velocity.x) > e.MAXSPEEDX)
     {
         e.body.velocity = new Vector2(e.MAXSPEEDX * Mathf.Sign(e.body.velocity.x), e.body.velocity.y);
     }
     return(null);
 }
 public void SwitchToAIControl()
 {
     if (currentPilot != null)
     {
         currentPilot.Disable();
     }
     currentPilot         = GetComponent <AIInput>();
     currentPilot.enabled = true;
 }
Example #5
0
        public async Task <Company> Get(EntityInput <Guid> input)
        {
            var item = await _context
                       .Companies
                       .Where(x => x.Id == input.Id)
                       .FirstOrDefaultAsync();

            return(item);
        }
    public override EnemyState HandleInput(EntityController e, EntityInput i)
    {
        e.CheckFlip(i.horz);

        if (Mathf.Abs(i.horz) > 0)
        {
            e.body.AddForce(e.transform.right * Mathf.Sign(i.horz) * e.ACCELX);
        }

        //Pass to GroundedState
        return(base.HandleInput(e, i));
    }
Example #7
0
 public override EnemyState Update(EntityController e, EntityInput i)
 {
     if (Mathf.Abs(e.body.velocity.x) <= e.SLOWDOWNTHRES && Mathf.Abs(e.body.velocity.x) > e.STOPTHRESH)
     {
         e.body.AddForce(new Vector2(Mathf.Sign(e.body.velocity.x), 0) * -e.ACCELSLOWDOWN);
     }
     else
     {
         e.Stop();
     }
     return(null);
 }
Example #8
0
    private void Start()
    {
        onGround   = false;
        canMove    = true;
        rb         = GetComponent <Rigidbody2D>();
        entityKeys = GetComponent <EntityInput>();

        if (dataToStore != null)
        {
            dataToStore.moveable     = true;
            dataToStore.walkVelocity = walkVelocity;
            dataToStore.runVelocity  = runVelocity;
        }
    }
Example #9
0
    void Start()
    {
        input          = GetComponent <EntityInput>();
        rigidbody      = GetComponent <Rigidbody2D>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        // Cache the jump velocity so we don't have to recalculate it every tick.
        // This will need to be recalculated if the input variables change.
        jumpVelocity = CalculateJumpVelocity();

        // For now, all entities use the same collision nodes, but later we could
        // optimise this by taking into account the size of the entity.
        collisionNodes = CreateCollisionNodes();
    }
Example #10
0
    // Start is called before the first frame update
    void Start()
    {
        rb                = GetComponent <Rigidbody2D>();
        animator          = GetComponent <Animator>();
        entityInput       = GetComponent <EntityInput>();
        cooldownComponent = new Cooldown(0);

        if (dataToStore != null)
        {
            dataToStore.jumpAble          = true;
            dataToStore.jumpVelocity      = jumpVelocity;
            dataToStore.fallMultiplier    = fallMultiplier;
            dataToStore.lowJumpMultiplier = lowJumpMultiplier;
        }
    }
 public override EnemyState HandleInput(EntityController e, EntityInput i)
 {
     if (!e.RayCastGround())
     {
         return(new EnemyFallingState());
     }
     else if (Mathf.Abs(i.horz) > 0)
     {
         return(new EnemyWalkingState());
     }
     else
     {
         return(new EnemyIdleState());
     }
 }
Example #12
0
    // Start is called before the first frame update
    void Start()
    {
        if (groundLayerMask == 0)
        {
            groundLayerMask = LayerMask.GetMask("Ground");
        }
        rb         = GetComponent <Rigidbody2D>();
        animator   = GetComponent <Animator>();
        entityKeys = GetComponent <EntityInput>();

        if (dataToStore != null)
        {
            dataToStore.wallDashable     = true;
            dataToStore.wallDashVelocity = dashVelocity;
        }
    }
    public override EnemyState Update(EntityController e, EntityInput i)
    {
        if (e.RayCastGround())
        {
            if (Mathf.Abs(i.horz) > 0)
            {
                return(new EnemyWalkingState());
            }
            else
            {
                return(new EnemyIdleState());
            }
        }

        return(null);
    }
 public override EnemyState Update(EntityController p, EntityInput i)
 {
     //Run once
     if (entered)
     {
         entered = false;
         Vector3 knockbackForce = dir;
         knockbackForce.y = 1 * knockback;
         knockbackForce.x = -Mathf.Sign(knockbackForce.x) * knockback;
         // Debug.Log(knockbackForce);
         p.body.AddForce(knockbackForce);
     }
     knockBackFrameCounter++;
     if (knockBackFrameCounter == KNOCKBACKFRAMES)
     {
         return(new EnemyFallingState());
     }
     return(null);
 }
    public override void Initialize(int ownerUniqueID)
    {
        this.ownerUniqueID = ownerUniqueID;
        identifier         = PStrings.entityController;

        input = new EntityInput();
        input.InitializeDefaults();
        attributes = new EntityAttributes();
        attributes.InitializeDefaults();
        state = new EntityState();
        state.InitializeDefaults();

        entityData       = (EntityData)GridData.GetExtensible(ownerUniqueID);
        rigidbody        = entityData.gameObject.GetComponent <Rigidbody>();
        weaponController = entityData.gameObject.GetComponent <WeaponController>();
        if (weaponController != null)
        {
            weaponController.Initialize(entityData);
        }
        waypointManager = (WaypointManagerData)entityData.GetExtension(PStrings.waypointManager);
        pathfindManager = (PathfindManagerData)entityData.GetExtension(PStrings.pathfindManager);

        state.rotationCurrent = Metrics.OrientationFromDirection[(int)entityData.orientation];
    }
Example #16
0
 public Task <bool> Delete(EntityInput <Guid> input)
 {
     throw new NotImplementedException();
 }
Example #17
0
 public async Task <Company> Get(EntityInput <Guid> input)
 {
     return(await _context.Companies.FindAsync(input.Id));
 }
Example #18
0
 public BaseState(GameObject obj, EntityInput aiInput)
 {
     this.obj          = obj;
     this.entityInputs = aiInput;
 }
Example #19
0
 public Patrol(GameObject obj, EntityInput EntityInputs, Vector2 left, Vector2 right, bool isPatrolToTheRight) : base(obj, EntityInputs)
 {
     patrolLoc_left          = left;
     patrolLoc_right         = right;
     this.isPatrolToTheRight = isPatrolToTheRight;
 }
Example #20
0
 public virtual EnemyState Update(EntityController e, EntityInput i)
 {
     return(null);
 }
Example #21
0
 // Start is called before the first frame update
 void Start()
 {
     cooldown   = new Cooldown(0);
     animator   = GetComponent <Animator>();
     entityKeys = GetComponent <EntityInput>();
 }
Example #22
0
 Task <Company> IBaseService <Guid, CompanyCreateInput, CompanyUpdateInput, Company> .Delete(EntityInput <Guid> input)
 {
     throw new NotImplementedException();
 }
Example #23
0
 private void Awake()
 {
     input = GetComponent <EntityInput>();
 }
Example #24
0
 public Attack(GameObject obj, EntityInput entityInputs) : base(obj, entityInputs)
 {
 }
 void Start()
 {
     input = GetComponent <EntityInput>();
 }
 public override EnemyState Update(EntityController e, EntityInput i)
 {
     return(null);
 }
Example #27
0
 public Chase(GameObject obj, EntityInput entityInputs, PlayerDetector detector) : base(obj, entityInputs)
 {
     this.detector = detector;
 }
Example #28
0
 public override EnemyState HandleInput(EntityController e, EntityInput i)
 {
     //Do nothing
     //Pass to GroundedState
     return(base.HandleInput(e, i));
 }
Example #29
0
 public virtual EnemyState HandleInput(EntityController e, EntityInput i)
 {
     return(null);
 }
Example #30
0
 protected override void Awake()
 {
     base.Awake();
     idleToPatrolTimer = new Cooldown(0);
     entityInputs      = GetComponent <EntityInput>();
 }