Пример #1
0
 private void MyAttack()
 {
     if (true)   //TODO: if shooting is done
     {
         m_state = EnumStates.Waiting;
     }
 }
Пример #2
0
        private static void ExecuteBuySell(MimeMessage message)
        {
            CurrencyPair currencyPair = null;

            // Enlève ceci: "TradingView Alert: "
            var valueSplit = message.Subject.Remove(0, 19).Split(',');

            currencyPair = new CurrencyPair(valueSplit[0].Trim().ToUpper());

            if (lastState == EnumStates.WAITING && message.Subject.Contains("sell"))
            {
                return;
            }
            else if (lastState == EnumStates.WAITING && message.Subject.Contains("buy"))
            {
                lastState = EnumStates.SOLD;
            }

            if (lastState == EnumStates.SOLD && message.Subject.Contains("buy"))
            {
                Console.WriteLine($"{DateTime.Now} - {message.Date.LocalDateTime} - {message.Subject.Remove(0, 19)}");
                lastState = EnumStates.BOUGHT;
                Buy(currencyPair);
            }
            else if (lastState == EnumStates.BOUGHT && message.Subject.Contains("sell"))
            {
                Console.WriteLine($"{DateTime.Now} - {message.Date.LocalDateTime} - {message.Subject.Remove(0, 19)}");
                lastState = EnumStates.SOLD;
                Sell(currencyPair);
            }
        }
Пример #3
0
 public Enemy(int x, int y, int _radius, int _height, EnumStates currState, bool toRight, uint[] _textures, int _texCount) : base(x, y, _height, 5, currState, _textures, _texCount)
 {
     radius    = _radius;
     startingX = x;
     if (toRight)
     {
         moveRight = true;
     }
     else
     {
         moveLeft = true;
     }
 }
Пример #4
0
 public MoveableObject(int x, int y, int _height, EnumStates currState, int maxVX = 0)
 {
     heightOfObject = _height;
     form           = new Tile[heightOfObject];
     for (int i = 0; i < heightOfObject; i++)
     {
         form[i] = new Tile(x, y + i * Tile.Size, currState);
     }
     position.X    = form[0].X;
     position.Y    = form[0].Y;
     maxVelocity.X = maxVX;
     //maxVelocity.Y = maxVY;
 }
Пример #5
0
    private void MyToOnRoute()
    {
        // Check if waypoint is reached
        if ((m_waypoint - transform.position).sqrMagnitude < 1)
        {
            // Get new waypoint
            var nextWaypoint = GameManager.GetInstance().GetNpcManager().GetLandNpcNextWaypoint(m_routeId, m_waypointId, m_direction);
            m_waypoint   = nextWaypoint.waypoint;
            m_waypointId = nextWaypoint.waypointId;
            m_direction  = nextWaypoint.direction;
        }

        // Either way continue movement
        m_state = EnumStates.OnRoute;
    }
Пример #6
0
    private void MyPrepareAttack()
    {
        // Check if we are looking at player
        Vector3 playerDirection = (player.position - transform.position).normalized;

        playerDirection.y = 0;
        Vector3 forwardDirection = transform.forward;

        forwardDirection.y = 0;
        if (Vector3.Angle(playerDirection, forwardDirection) > 5)
        {
            MyRotateTowards(player.position);
        }
        else
        {
            MyShoot();
            m_state = EnumStates.Attacking;
        }
    }
Пример #7
0
    private void MyMove()
    {
        // Check if waypoint is reached
        if ((m_waypoint - transform.position).sqrMagnitude < 1)
        {
            // Wait for orders
            m_state = EnumStates.Waiting;
        }
        else
        {
            // Movement
            // Check for obstacles
            if ((m_controller.collisionFlags & CollisionFlags.CollidedSides) == CollisionFlags.CollidedSides)
            {
                transform.Rotate(transform.up, rotationSpeed * Time.deltaTime);  // obstacle, avoid by turning
            }
            else
            {
                // no obstacle, turn towards waypoint
                MyRotateTowards(m_waypoint);
            }

            m_controller.SimpleMove(transform.forward * moveSpeed);
        }

        if (UnityEngine.Random.Range(0, 1200) == 0)  //TODO: different attack randomization
        {
            // Check if we can see player. If so, attack. If not, keep moving.
            RaycastHit hit;
            if (Physics.Raycast(transform.position, player.position - transform.position, out hit))
            {
                if ((null != hit.collider) && (hit.collider.gameObject.tag == "Player"))
                {
                    m_state = EnumStates.PrepareAttack;
                }
            }
        }
    }
Пример #8
0
        private static void GetBalance(CurrencyPair currencyPair, bool showBalance)
        {
            IList <BalanceModel> balances = (from x in BIZ.GetBalances() select x).ToList();

            var balanceBase  = (from x in balances where x.Type == currencyPair.BaseCurrency select x.QuoteAvailable).SingleOrDefault();
            var balanceQuote = (from x in balances where x.Type == currencyPair.QuoteCurrency select x.USDT_Value).SingleOrDefault();

            if (showBalance)
            {
                Console.WriteLine($"Balance USDT    : {balanceBase} USDT");
                Console.WriteLine($"Balance {currencyPair}: {balanceQuote} USDT");
            }

            if (balanceQuote < 1)
            {
                lastState = EnumStates.SOLD;
            }
            else
            {
                lastState = EnumStates.BOUGHT;
            }

            //Console.WriteLine($"lastState: {lastState}\n");
        }
Пример #9
0
        public void ChangeState(EnumStates newState, params object[] parameters)
        {
            switch (newState)
            {
            case EnumStates.Move:
                if (parameters != null && parameters.Length == 2)
                {
                    Move((float)parameters[0], (float)parameters[1]);
                }
                else
                {
                    throw new ArgumentException("MoveState nécessite l'utilisation de deux paramètres DirX et DirY");
                }
                break;

            case EnumStates.Attack:
                Attack();
                break;

            default:
                Idle();
                break;
            }
        }
Пример #10
0
 public Tile(int x, int y, EnumStates _state)
 {
     begin.X = x;
     begin.Y = y;
     state   = _state;
 }
Пример #11
0
 public Character(int x, int y, int _height, int maxVX, EnumStates state, uint[] _textures, int _texCount) : base(x, y, _height, state, maxVX)
 {
     textures = _textures;
     texCount = _texCount;
     k        = 0;
 }