Exemplo n.º 1
0
 public void InitText(Vector2 dir, float rot, float spd, MoveFunctions act, bool enemy)
 {
     MoveVector = dir.normalized * spd;
     Rotation   = rot;
     MoveFunc   = getMoveFunction(act);
     hostile    = enemy;
     letter     = true;
 }
Exemplo n.º 2
0
    public void Init(Vector2 dir, float rot, float spd, MoveFunctions act, Sprite spr, Color color, bool enemy)
    {
        SpriteRenderer sp = GetComponent <SpriteRenderer>();

        MoveVector = dir.normalized * spd;
        Rotation   = rot;
        MoveFunc   = getMoveFunction(act); sp.sprite = spr;
        sp.color   = color; hostile = enemy;
    }
Exemplo n.º 3
0
 public StandardLibrary(GameContext context)
 {
     Context = context;
     D3d     = new D3dFunctions(context);
     Drawing = new DrawingFunctions(context);
     Main    = new MainFunctions(context);
     Move    = new MoveFunctions(context);
     Real    = new RealFunctions(context);
     Actions = new ActionLibrary(context);
 }
Exemplo n.º 4
0
    public Action getMoveFunction(MoveFunctions f)
    {
        switch (f)
        {
        case MoveFunctions.LeftSine: return(LeftSine);

        case MoveFunctions.RightSine: return(RightSine);

        case MoveFunctions.Spin: return(Spin);

        default: return(null);
        }
    }
        private void _HandleAimPhysicsProcess(float delta)
        {
            if (!CanProcessAim || AimTarget == null)
            {
                return;
            }
            var rotation = MoveFunctions.RotateLerpChecked(Rotation,
                                                           AimTarget.Value.AngleToPoint(Position),
                                                           MaximumAngularSpeed,
                                                           ANGULAR_START_THRESHOLD,
                                                           delta);

            if (rotation != null)
            {
                TargetAngle = rotation.Value;
            }
        }
Exemplo n.º 6
0
        void ISystem.OperateOnEntity(Entity e)
        {
            EnergyHaver energyComp = e.GetComponent <EnergyHaver>();
            AI          ai         = e.GetComponent <AI>();

            // keep taking moves until out of energy
            while (energyComp.CanTakeAction())
            {
                // assign a target if needed
                if (ai.Target == null)
                {
                    AssignTarget(e);
                }

                if (ai.State == AIState.Pursuing)
                {
                    Position posComp       = e.GetComponent <Position>();
                    Position targetPosComp = ai.Target.GetComponent <Position>();

                    // if the entity is adjacent to its target
                    if (OrderedPair.Adjacent(posComp.Pos, targetPosComp.Pos))
                    {
                        // attack the target
                        energyComp.Energy -= GameManager.COST_ATTACK;
                        AttackFunctions.BumpAttack(e, ai.Target);
                    }
                    else
                    {
                        // move towards the target
                        energyComp.Energy -= GameManager.COST_MOVE;
                        OrderedPair towards = OrderedPair.Towards(posComp.Pos, targetPosComp.Pos);
                        MoveFunctions.Move(e, posComp.Pos + towards);
                    }

                    continue;
                }

                break;
            }
        }
Exemplo n.º 7
0
    public void Init(Vector2 dir, float rot, float spd, MoveFunctions act, SpawnFunctions spwn, Sprite spr, Color color, bool enemy, float colliderX = 0.5f, float colliderY = 0.5f, List <float> SpawnFunctionParams = null)
    {
        SpriteRenderer sp = GetComponent <SpriteRenderer>();

        MoveVector         = dir.normalized * spd;
        speed              = spd;
        Rotation           = rot;
        transform.rotation = Quaternion.identity;
        transform.Rotate(new Vector3(0, 0, rot));
        MoveFunc = getMoveFunction(act); sp.sprite = spr;
        sp.color = color; hostile = enemy;
        if (GetComponent <BoxCollider2D>())
        {
            GetComponent <BoxCollider2D>().size = new Vector2(colliderX, colliderY);
        }
        else
        {
            Debug.Log("Missing Collider Component, please add a BoxCollider2D!");
        }

        getSpawnFunction(spwn)?.Invoke(SpawnFunctionParams.ToArray());
    }