Ejemplo n.º 1
0
    private bool Move()
    {
        speed += ACCELERATE * TimeHelper.deltaTime;
        speed  = Mathf.Min(speed, SPEED_MAX);

        float rotSpeed = speed / SPEED_MAX * SPEED_ROTATE;


        Vector3 destination = GetCurrentDestination();

        AimmingControl.RESULT rotateR = AimmingControl.Rotate(
            transform.position, destination, transform.rotation.eulerAngles.y, rotSpeed, 0.01f);
        transform.Rotate(new Vector3(0, rotateR.turnDegree, 0));


        Vector3 line = destination - transform.position;
        float   dist = line.magnitude;

        Vector3 orientation = UnitHelper.GetOrientation(transform);

        VectorHelper.ResizeVector(ref orientation, dist);
        Vector3 p = orientation + transform.position;

        float radius = _shoot.target.unit.dataUnit.GetHurtRadius();

        MovingControl.RESULT moveR = MovingControl.MoveTo(transform.position, p, speed, radius + heightInitOffset);
        transform.position = moveR.destination;


        return(moveR.arrived);
    }
Ejemplo n.º 2
0
    // STANDARD METHODS

    // Used for initialization
    void Start()
    {
        rb2d    = base.GetComponent <Rigidbody2D>();
        anim    = base.GetComponent <Animator>();
        colider = base.GetComponent <Collider2D>();

        hero          = GameObject.FindGameObjectWithTag("Player");
        enemyManager  = base.GetComponent <Enemy>();
        heroManager   = hero.GetComponent <HeroManager>();
        movingControl = hero.GetComponent <MovingControl>();
    }
Ejemplo n.º 3
0
 // STANDARD METHODS
 // Start is called before the first frame update
 void Start()
 {
     anim          = GetComponent <Animator>();
     rb2d          = GetComponent <Rigidbody2D>();
     player        = GameObject.FindGameObjectWithTag("Player");
     movingControl = player.GetComponent <MovingControl>();
     heroManager   = player.GetComponent <HeroManager>();
     enemyManager  = base.GetComponent <Enemy>();
     position      = base.transform.position;
     fightControl  = player.GetComponent <FightControl>();
 }
Ejemplo n.º 4
0
    public int currentSaveNumber = 0;   //currently chosen save

    // STANDARD METHODS

    // Used for initialization
    void Start()
    {
        health_points     = transform.Find("Canvas/Text").gameObject;
        heroMovingControl = base.GetComponent <MovingControl>();
        fightControl      = base.GetComponent <FightControl>();

        // loading save
        if (PlayerPrefs.GetInt("CurrentSave") >= 1 && PlayerPrefs.GetInt("CurrentSave") <= 5)             // currentSaveNumber != 0)
        {
            LoadHero();
        }
    }
Ejemplo n.º 5
0
 void Start()
 {
     hero          = GameObject.FindGameObjectWithTag("Player");
     rb2d          = base.GetComponent <Rigidbody2D>();
     movingControl = hero.GetComponent <MovingControl>();
     // Odczytywanie save'a
     if (PlayerPrefs.HasKey("HeroPositionX"))          // Jeśli wybrana została opcja NewGame, to PlayerPrefs jest puste
     {
         transform.position = new Vector3(PlayerPrefs.GetFloat("HeroPositionX"), PlayerPrefs.GetFloat("HeroPositionY"), -10);
     }
     PlayerPrefs.DeleteAll();
 }
Ejemplo n.º 6
0
    public void FindAllPossibleMoves(List <List <Action> > actions, GameObject[,] grid, Square[,] gameBoard, Material material1, Material material2, Material material4)
    {
        possibleMoves = new MovingControl();

        List <List <Action> > moves = new List <List <Action> >();
        List <int>            li    = new List <int>();

        for (int i = 0; i < actions.Count; i++)
        {
            for (int j = 0; j < actions[i].Count; j++)
            {
                if (actions[i][j].Src.R == row && actions[i][j].Src.C == col)
                {
                    li.Add(i);
                }
            }
        }
        for (int i = 0; i < actions.Count; i++)
        {
            foreach (int j in li)
            {
                if (j == i)
                {
                    moves.Add(actions[i]);
                }
            }
        }
        foreach (List <Action> a in moves)
        {
            possibleMoves.AddPossiblePath(fillPath(a, gameBoard));
        }
        foreach (Square square in possibleMoves.GetAllFinalTargets())
        {
            square.HighLightMove(material4);
        }
        foreach (List <Square> list in possibleMoves.GetAllPathsEmpty())
        {
            foreach (Square square1 in list)
            {
                if (grid[square1.row, square1.col] != null)
                {
                    square1.HighLightMove(material2);
                }
                else
                {
                    square1.HighLightMove(material1);
                }
            }
        }
    }
Ejemplo n.º 7
0
    // ==================================================================
    // algorithm

    private MovingControl.RESULT Move(Vector3 targetPosition, bool testCollision)
    {
        float   moveDist;
        float   dist;
        float   speed       = _speed * _engine.speedScale;
        Vector3 orientation = UnitHelper.GetOrientation(_body.transform);
        Vector3 destination = MovingControl.CalcDestinationWithOrientation(_owner.transform.position, targetPosition, speed, orientation,
                                                                           out moveDist, out dist);

        if (testCollision)
        {
            UnitCollisionDetector.RESULT cr =
                _unit.collisionDetector.Detect_withOrientationTest(destination);
            if (cr != null)
            {
                MovingControl.RESULT r = new MovingControl.RESULT();
                r.blocked = true;
                r.arrived = false;
                return(r);
            }
        }

        bool isBlocked = IsDestinationBlocked(destination);

        if (isBlocked)
        {
            MovingControl.RESULT r = new MovingControl.RESULT();
            r.blocked = true;
            r.arrived = false;
            return(r);
        }
        else
        {
            _owner.transform.position = destination;

            MovingControl.RESULT r = new MovingControl.RESULT();
            r.distance     = moveDist;
            r.distanceLeft = dist - moveDist;
            r.destination  = destination;
            r.arrived      = (r.distanceLeft <= 0.01f);
            return(r);
        }
    }
Ejemplo n.º 8
0
        private void button_mc_Click(object sender, EventArgs e)
        {
            if (button_mc.Text == TB.L.Phrase["Form_PrintMaster.Disconnect"])
            {
                combobox_bdrate.Enabled = true;
                combobox_com.Enabled    = true;
                master?.CloseConnection();
                button_mc.Text = TB.L.Phrase["Form_PrintMaster.Connect"];
                return;
            }
            try
            {
                var port = new SerialPort(combobox_com.Text, int.Parse(combobox_bdrate.Text.Remove(0, 2)));
                port.Open();
                var Listener = new PacketListener(new SerialPacketReader(port, 3000), new SerialPacketWriter(port));
                master        = new DTPMaster(new Sender("Coestar"), Listener);
                Pens          = master.PlotterConfig().Pens;
                movingControl = master.PlotterMovingControl();
                comboBox1.Items.Clear();
                comboBox1.Items.AddRange(Pens.Select(p => p.Name).ToArray());
                comboBox1.SelectedIndex = 0;
                //Control.Enabled = true;
                combobox_bdrate.Enabled = false;
                combobox_com.Enabled    = false;
                button_mc.Text          = TB.L.Phrase["Form_PrintMaster.Disconnect"];

                if (master.SecurityManager.IsValidationRequired)
                {
                    if (new ValidateForm(master).ShowDialog() != DialogResult.OK)
                    {
                        combobox_bdrate.Enabled = true;
                        combobox_com.Enabled    = true;
                        master?.CloseConnection();
                        button_mc.Text = TB.L.Phrase["Form_PrintMaster.Connect"];
                    }
                }
            }
            catch { MessageBox.Show(
                        string.Format(TB.L.Phrase["Connection.UnableToOpenPort"], combobox_com.Text),
                        TB.L.Phrase["Connection.Error"],
                        MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
Ejemplo n.º 9
0
        public void ReturnUpdatedCoordinates_WhenCorrectCommand(char command, string direction, int startingX,
                                                                int startingY, int expectedX, int expectedY)
        {
            var expectedResult = new Coordinates
            {
                X = expectedX,
                Y = expectedY
            };

            var startingCoordinates = new Coordinates
            {
                X = startingX,
                Y = startingY
            };

            var movingControl = new MovingControl();
            var actualResult  = movingControl.Move(command, direction, startingCoordinates);

            actualResult.Should().BeEquivalentTo(expectedResult);
        }
Ejemplo n.º 10
0
        public Location FinalLocation(string way, Location start)
        {
            Location stop = new Location();

            stop = start;
            foreach (var item in way)
            {
                if (item == 'L' || item == 'R')
                {
                    SpinningControl spin = new SpinningControl();
                    var             data = spin.GetNextDirection(item, stop);
                    stop = data;
                }
                else
                {
                    MovingControl move = new MovingControl();
                    var           data = move.MoveNextDirection(stop);
                    stop = data;
                }
            }

            return(stop);
        }
Ejemplo n.º 11
0
        public Location FinalLocation(string way, Location start)  // Örnek = konumu ( 1 2 N )  -  komutları ( LMLMLMLMM )
        {
            Location stop = new Location();

            stop = start;
            foreach (var item in way)  // her hareketi ve o anki lokasyonunu metotlara gönderip son hareketini çekiyoruz.
            {
                if (item == 'L' || item == 'R')
                {
                    SpinningControl spin = new SpinningControl();
                    var             data = spin.GetNextDirection(item, stop);
                    stop = data;
                }
                else
                {
                    MovingControl move = new MovingControl();
                    var           data = move.MoveNextDirection(stop);
                    stop = data;
                }
            }

            return(stop);
        }
Ejemplo n.º 12
0
    // STANDARD METHODS

    // Used for initialization
    void Start()
    {
        health_points     = transform.Find("Canvas/Text").gameObject;
        heroMovingControl = base.GetComponent <MovingControl>();
        fightControl      = base.GetComponent <FightControl>();
    }
Ejemplo n.º 13
0
    // STANDART METHODS

    // Used for initialization
    void Start()
    {
        movingControl = base.GetComponent <MovingControl>();
        hand          = GameObject.FindGameObjectWithTag("Hand");
        anim          = hand.GetComponent <Animator>();
    }
Ejemplo n.º 14
0
 void Start()
 {
     hero          = GameObject.FindGameObjectWithTag("Player");
     rb2d          = base.GetComponent <Rigidbody2D>();
     movingControl = hero.GetComponent <MovingControl>();
 }