public CircularWaypointMotionProvider(AIPath path, AIDestinationSetter destinationSetter, Transform self, IEnumerable <Transform> waypoints)
     : base(path, destinationSetter, self, waypoints)
 {
 }
Ejemplo n.º 2
0
 private void Awake()
 {
     AIPath            = GetComponent <AIPath>();
     DestinationSetter = GetComponent <AIDestinationSetter>();
 }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     attacker          = GameObject.FindWithTag(Tags.Attacker);
     charger           = GameObject.FindWithTag(Tags.Charger);
     destinationSetter = GetComponent <AIDestinationSetter> ();
 }
Ejemplo n.º 4
0
 public ChaseHandler(Animator animator, Rigidbody2D rb, Transform transform, float speed, AIDestinationSetter _pathfinder)
 {
     enemyAnimator  = animator;
     enemyRigidBody = rb;
     enemyTransform = transform;
     enemySpeed     = speed;
     pathfinder     = _pathfinder;
 }
Ejemplo n.º 5
0
 void Start()
 {
     player            = GameObject.Find("Player");
     ai                = GetComponent <AIPath>();
     destinationSetter = GetComponent <AIDestinationSetter>();
 }
Ejemplo n.º 6
0
 void Start()
 {
     destinationSetter = GetComponent <AIDestinationSetter>();
     aiPath            = GetComponent <AIPath>();
     // InitializeSettings(); // todo: find out why this line doesnt work
 }
Ejemplo n.º 7
0
 protected WaypointMotionProvider(AIPath path, AIDestinationSetter destinationSetter, Transform self, IEnumerable <Transform> waypoints)
     : base(path, destinationSetter, self)
 {
     Threshold  = 0.1f;
     _waypoints = waypoints?.ToArray();
 }
Ejemplo n.º 8
0
 // Use this for initialization
 void Awake()
 {
     controller = GetComponent <GameController>();
     destSetter = player.GetComponent <AIDestinationSetter>();
     nearTarget = false;
 }
Ejemplo n.º 9
0
 private void Awake()
 {
     _aiDestinationSetter = GetComponent <AIDestinationSetter>();
     Power = _power;
     _rb   = GetComponent <Rigidbody2D>();
 }
Ejemplo n.º 10
0
 // Start is called before the first frame update
 void Start()
 {
     aIDestinationSetter = GetComponent <AIDestinationSetter>();
 }
Ejemplo n.º 11
0
 void Awake()
 {
     destinationSetter = GetComponent <AIDestinationSetter>();
 }
 // Start is called before the first frame update
 void Start()
 {
     destinationSetter = GetComponent <AIDestinationSetter>();
     aIPath            = GetComponent <AIPath>();
 }
Ejemplo n.º 13
0
 public override void OnReset()
 {
     Target.Value      = null;
     destinationSetter = null;
 }
Ejemplo n.º 14
0
 // Start is called before the first frame update
 void Start()
 {
     keyObject              = Instantiate(keyPrefab, transform.position, Quaternion.Euler(0f, 0f, 0f));
     keyTargetScript        = keyObject.GetComponent <AIDestinationSetter>();
     keyTargetScript.target = transform;
 }
Ejemplo n.º 15
0
 private void Start()
 {
     ds = GetComponent <AIDestinationSetter>();
 }
Ejemplo n.º 16
0
 public override void OnReset()
 {
     Target.Value           = null;
     StoppingDistance.Value = 0;
     destinationSetter      = null;
 }
Ejemplo n.º 17
0
 public AITargetForwarder(AIDestinationSetter aiDestinationSetter, AITargetScanner aiTargetScanner)
 {
     _aiDestinationSetter = aiDestinationSetter;
     _aiTargetScanner     = aiTargetScanner;
 }
Ejemplo n.º 18
0
 // Start is called before the first frame update
 void Start()
 {
     destinationSetter        = GetComponent <AIDestinationSetter>();
     player                   = GameObject.FindGameObjectWithTag("Player");
     destinationSetter.target = player.transform;
 }
Ejemplo n.º 19
0
 private void Start()
 {
     destinationSetter  = GetComponent <AIDestinationSetter>();
     aiPath             = GetComponent <AIPath>();
     embodimentAnimator = GetComponentInChildren <Animator>();
 }
Ejemplo n.º 20
0
 private void Start()
 {
     m_setter = GetComponent <AIDestinationSetter>();
     StartCoroutine(LookForPlayer());
 }
Ejemplo n.º 21
0
 void Start()
 {
     seeker = GetComponent <Seeker>();
     target = GetComponent <AIDestinationSetter>();
 }
Ejemplo n.º 22
0
 // Start is called before the first frame update
 void Start()
 {
     aids        = GetComponent <AIDestinationSetter>();
     aids.target = FindObjectOfType <Player>().transform;
 }
Ejemplo n.º 23
0
    // Update is called once per frame
    void Update()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit, Mathf.Infinity, MouseLayerMask))
        {
            currentMousePoint = hit.point;
            #region Visszavonások
            if (GUISetup.GhostActive)
            {
                return;
            }
            #endregion
            //Store point at mouse button down
            if (Input.GetMouseButtonDown(0))
            {
                if (EventSystem.current.IsPointerOverGameObject())
                {
                    EndModes();
                }
                mouseDownPoint            = hit.point;
                TimeLeftBeforeDeclareDrag = TimeLimitBeforeDeclareDrag;
                MouseDragStart            = Input.mousePosition;
                StartedDrag = true;

                #region CommandRegion
                if (MoveMode)
                {
                    for (int i = 0; i < CurrentlySelectedUnits.Count; i++)
                    {
                        AIDestinationSetter setter = (CurrentlySelectedUnits[i] as GameObject).GetComponent <AIDestinationSetter>();
                        if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Unit"))
                        {
                            setter.target = hit.collider.gameObject.transform;
                        }
                        else
                        {
                            setter.ai.destination = mouseDownPoint;
                        }
                        setter.ai.isStopped = false;
                    }
                    MoveMode = false;
                }
                if (AttackMode)
                {
                    for (int i = 0; i < CurrentlySelectedUnits.Count; i++)
                    {
                        AIDestinationSetter setter = (CurrentlySelectedUnits[i] as GameObject).GetComponent <AIDestinationSetter>();
                        if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Unit"))
                        {
                            setter.target = hit.collider.gameObject.transform;
                        }
                        else
                        {
                            setter.ai.destination = mouseDownPoint;
                            (CurrentlySelectedUnits[i] as GameObject).GetComponent <Unit>().aMove = true;
                        }
                        setter.ai.isStopped = false;
                    }
                    AttackMode = false;
                }

                if (RepairMode)
                {
                    for (int i = 0; i < CurrentlySelectedUnits.Count; i++)
                    {
                        AIDestinationSetter setter = (CurrentlySelectedUnits[i] as GameObject).GetComponent <AIDestinationSetter>();
                        Unit unit = (CurrentlySelectedUnits[i] as GameObject).GetComponent <Unit>();
                        if (unit.isGatherer && hit.collider.gameObject.layer == LayerMask.NameToLayer("Unit") &&
                            !Game.players.Where(x => x.empireName.Equals(unit.Owner)).SingleOrDefault().enemies.Contains(Game.players.Where(x => x.empireName.Equals(hit.collider.transform.GetComponent <Unit>().Owner)).SingleOrDefault()))
                        {
                            setter.target       = hit.collider.gameObject.transform;
                            setter.ai.isStopped = false;
                        }
                    }
                    RepairMode = false;
                }
                #endregion
            }
            else if (Input.GetMouseButton(0))
            {
                //If the user is not dragging, lets do the tests
                if (!UserIsDragging)
                {
                    TimeLeftBeforeDeclareDrag = Time.deltaTime;
                    if (TimeLeftBeforeDeclareDrag <= 0f || UserDraggingByPosition(MouseDragStart, Input.mousePosition))
                    {
                        UserIsDragging = true;
                    }
                }
            }
            else if (Input.GetMouseButtonUp(0))
            {
                //User is dragging
                if (UserIsDragging)
                {
                    FinishedDragOnThisFrame = true;
                }
                UserIsDragging = false;
            }

            //Mouse click
            if (!UserIsDragging)
            {
                //Debug.Log(hit.collider.name);

                #region Jobb klikk
                if (Input.GetMouseButtonDown(1) && !EventSystem.current.IsPointerOverGameObject())
                {
                    if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Unit"))
                    {
                        SelectTargets(hit);
                    }
                    else if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Resources"))
                    {
                        SelectGatherTargets(hit);
                    }
                    else if (hit.collider.name == "TerrainMain")
                    {
                        SelectRally(hit);
                        RightClickPoint = hit.point;
                        DeselectTargets();
                    }
                }
                #endregion

                // End of Terrain
                else
                {
                    //Hitting other objects
                    if (Input.GetMouseButtonUp(0) && DidUserClickLeftMouse(mouseDownPoint) && !EventSystem.current.IsPointerOverGameObject())
                    {
                        //Is the user hitting a unit?
                        if ((hit.collider.gameObject.GetComponent <Unit>() || hit.collider.gameObject.layer == LayerMask.NameToLayer("SelectMesh")) && hit.collider.transform.parent.parent.name == game.currentSolarSystem.Name)
                        {
                            Transform UnitGameObject;
                            if (hit.collider.gameObject.layer == LayerMask.NameToLayer("SelectMesh"))
                            {
                                UnitGameObject = hit.collider.transform.parent.transform;
                            }
                            else
                            {
                                UnitGameObject = hit.collider.transform;
                            }

                            //Are we selecting a different object?
                            if (!UnitAlreadyInCurrentySelectedUnits(UnitGameObject.gameObject))
                            {
                                //If shift key is not down, remove the rest of the units
                                if (!Common.ShiftKeysDown())
                                {
                                    DeselectGameObjectsIfSelected();
                                }

                                GameObject SelectedObj = UnitGameObject.Find("Selected").gameObject;
                                if (UnitGameObject.GetComponent <Unit>().Owner != Game.currentPlayer.empireName)
                                {
                                    DeselectGameObjectsIfSelected();
                                    SelectedObj.GetComponent <Projector>().material.color = Color.red;
                                }
                                else
                                {
                                    SelectedObj.GetComponent <Projector>().material.color = Color.green;
                                }
                                SelectedObj.SetActive(true);

                                //Add unit to currently selected units
                                CurrentlySelectedUnits.Add(UnitGameObject.gameObject);

                                //Change the unit selected value to true
                                UnitGameObject.gameObject.GetComponent <Unit>().Selected = true;
                            }
                            else
                            {
                                //Unit is currently in the selected units arraylist
                                //Remove the units
                                if (Common.ShiftKeysDown())
                                {
                                    RemoveUnitFromCurrentlySelectedUnits(UnitGameObject.gameObject);
                                }
                                else if (!Common.ShiftKeysDown())
                                {
                                    DeselectGameObjectsIfSelected();

                                    GameObject SelectedObj = UnitGameObject.Find("Selected").gameObject;
                                    if (UnitGameObject.GetComponent <Unit>().Owner != Game.currentPlayer.empireName)
                                    {
                                        SelectedObj.GetComponent <Projector>().material.color = Color.red;
                                    }
                                    else
                                    {
                                        SelectedObj.GetComponent <Projector>().material.color = Color.green;
                                    }
                                    SelectedObj.SetActive(true);
                                    UnitGameObject.gameObject.GetComponent <Unit>().Selected = true;

                                    //Add unit to currently selected units
                                    CurrentlySelectedUnits.Add(UnitGameObject.gameObject);
                                }
                            }
                        }
                        else
                        {
                            //If this object is not a unit
                            if (!Common.ShiftKeysDown() && !EventSystem.current.IsPointerOverGameObject())
                            {
                                DeselectGameObjectsIfSelected();
                            }
                        }
                    }
                }
            }
            else
            {
                if (Input.GetMouseButtonUp(0) && DidUserClickLeftMouse(mouseDownPoint) && !EventSystem.current.IsPointerOverGameObject())
                {
                    if (!Common.ShiftKeysDown())
                    {
                        DeselectGameObjectsIfSelected();
                    }
                }
            }
            //End of dragging
        } //End of raycasthit

        if (CurrentlySelectedUnits.Count != 0)
        {
            CurrentlyFocusedUnit = CurrentlySelectedUnits[0] as GameObject;
        }
        else
        {
            CurrentlyFocusedUnit = null;
        }

        if (!Common.ShiftKeysDown() && StartedDrag && UserIsDragging)
        {
            DeselectGameObjectsIfSelected();
            StartedDrag = false;
        }
        #region Csoport létrehozás
        if (CurrentlySelectedUnits.Count != 0 && (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)))
        {
            for (int i = 1; i < 10; i++)
            {
                if (Input.GetKey(keyCodes[i - 1]))
                {
                    Grouping[i] = new ArrayList();
                    for (int j = 0; j < CurrentlySelectedUnits.Count; j++)
                    {
                        if ((CurrentlySelectedUnits[j] as GameObject).GetComponent <Unit>().Owner == Game.currentPlayer.empireName)
                        {
                            Grouping[i].Add(CurrentlySelectedUnits[j]);
                        }
                    }
                    Debug.Log(Grouping[i].Count);
                }
            }
        }
        #endregion

        #region Csoport kiválasztás
        if (GetAnyKey(keyCodes))
        {
            for (int i = 1; i < 10; i++)
            {
                if (Input.GetKey(keyCodes[i - 1]) && Grouping[i] != null)
                {
                    DeselectGameObjectsIfSelected();
                    for (int j = 0; j < Grouping[i].Count; j++)
                    {
                        CurrentlySelectedUnits.Add((Grouping[i])[j]);
                    }
                }
            }
            Debug.Log(CurrentlySelectedUnits.Count);
            for (int j = 0; j < CurrentlySelectedUnits.Count; j++)
            {
                GameObject SelectedObj = CurrentlySelectedUnits[j] as GameObject;
                SelectedObj.GetComponent <Unit>().Selected = true;
                SelectedObj.transform.Find("Selected").gameObject.SetActive(true);
                Debug.Log(j + ". aktív");
            }
        }
        #endregion

        Debug.DrawRay(ray.origin, ray.direction * 1000, Color.yellow);

        #region Dragbox variables
        if (UserIsDragging && currentMousePoint != Vector3.positiveInfinity)
        {
            BoxWidth  = Camera.main.WorldToScreenPoint(mouseDownPoint).x - Camera.main.WorldToScreenPoint(currentMousePoint).x;
            BoxHeight = Camera.main.WorldToScreenPoint(mouseDownPoint).y - Camera.main.WorldToScreenPoint(currentMousePoint).y;

            BoxLeft = Input.mousePosition.x;
            BoxTop  = (Screen.height - Input.mousePosition.y) - BoxHeight;

            if (Common.FloatToBool(BoxWidth))
            {
                if (Common.FloatToBool(BoxHeight))
                {
                    BoxStart = new Vector2(Input.mousePosition.x, Input.mousePosition.y + BoxHeight);
                }
                else
                {
                    BoxStart = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
                }
            }
            else
            if (!Common.FloatToBool(BoxWidth))
            {
                if (Common.FloatToBool(BoxHeight))
                {
                    BoxStart = new Vector2(Input.mousePosition.x + BoxWidth, Input.mousePosition.y + BoxHeight);
                }
                else
                {
                    BoxStart = new Vector2(Input.mousePosition.x + BoxWidth, Input.mousePosition.y);
                }
            }

            BoxFinish = new Vector2(BoxStart.x + Mathf.Abs(BoxWidth), BoxStart.y - Mathf.Abs(BoxHeight));
        }
        #endregion
    }
Ejemplo n.º 24
0
 private void Awake()
 {
     mAnimator         = GetComponent <Animator>();
     mAIAgent          = this.transform.parent.GetComponent <AIPath>();
     DestinationSetter = this.transform.parent.GetComponent <AIDestinationSetter>();
 }
Ejemplo n.º 25
0
 private void OnEnable()
 {
     destinationSetter = GetComponent <AIDestinationSetter>();
     path = GetComponent <AIPath>();
     destinationSetter.target = GameObject.FindGameObjectWithTag("Player").transform;
 }
Ejemplo n.º 26
0
    public DetectionSystem(Transform transform, Transform player1, Transform player2, float detectionRange, AIDestinationSetter pathfinder)
    {
        enemyTransform      = transform;
        this.detectionRange = detectionRange;
        this.player1        = player1;
        this.player2        = player2;
        this.pathfinder     = pathfinder;

        player1Variables = player1.GetComponent <Player>();
        player2Variables = player2.GetComponent <Player>();
    }
Ejemplo n.º 27
0
 void Start()
 {
     this.seeker            = GetComponent <Seeker>();
     this.rb                = GetComponent <Rigidbody2D>();
     this.destinationSetter = this.GetComponent <AIDestinationSetter>();
 }
Ejemplo n.º 28
0
 // Use this for initialization
 override protected void onStart()
 {
     timeBtwShots    = startTimeBtwShots;
     aiSetter        = GetComponent <AIDestinationSetter>();
     aiSetter.target = player;
 }
Ejemplo n.º 29
0
 private void OnValidate()
 {
     destinationSetter = GetComponent <AIDestinationSetter>();
     aIPath            = GetComponent <AIPath>();
 }
Ejemplo n.º 30
0
 void Awake()
 {
     rb       = GetComponent <Rigidbody2D>();
     pathfind = GetComponent <AIDestinationSetter>();
     hp       = GetComponentInParent <EnemyHealth>();
 }