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;
 }
Exemple #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));
    }
 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);
 }
Exemple #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;
        }
    }
Exemple #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();
    }
Exemple #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());
     }
 }
Exemple #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];
    }
Exemple #16
0
 public Task <bool> Delete(EntityInput <Guid> input)
 {
     throw new NotImplementedException();
 }
Exemple #17
0
 public async Task <Company> Get(EntityInput <Guid> input)
 {
     return(await _context.Companies.FindAsync(input.Id));
 }
Exemple #18
0
 public BaseState(GameObject obj, EntityInput aiInput)
 {
     this.obj          = obj;
     this.entityInputs = aiInput;
 }
Exemple #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;
 }
Exemple #20
0
 public virtual EnemyState Update(EntityController e, EntityInput i)
 {
     return(null);
 }
Exemple #21
0
 // Start is called before the first frame update
 void Start()
 {
     cooldown   = new Cooldown(0);
     animator   = GetComponent <Animator>();
     entityKeys = GetComponent <EntityInput>();
 }
 Task <Company> IBaseService <Guid, CompanyCreateInput, CompanyUpdateInput, Company> .Delete(EntityInput <Guid> input)
 {
     throw new NotImplementedException();
 }
Exemple #23
0
 private void Awake()
 {
     input = GetComponent <EntityInput>();
 }
Exemple #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);
 }
Exemple #27
0
 public Chase(GameObject obj, EntityInput entityInputs, PlayerDetector detector) : base(obj, entityInputs)
 {
     this.detector = detector;
 }
 public override EnemyState HandleInput(EntityController e, EntityInput i)
 {
     //Do nothing
     //Pass to GroundedState
     return(base.HandleInput(e, i));
 }
Exemple #29
0
 public virtual EnemyState HandleInput(EntityController e, EntityInput i)
 {
     return(null);
 }
Exemple #30
0
 protected override void Awake()
 {
     base.Awake();
     idleToPatrolTimer = new Cooldown(0);
     entityInputs      = GetComponent <EntityInput>();
 }