Esempio n. 1
0
 override protected void Awake()
 {
     base.Awake();
     movementBehaviour   = GetComponent <MovementBehaviour>();
     attackBehaviour     = GetComponent <AttackBehaviour>();
     TimeManager.OnTick += OnTick;
 }
Esempio n. 2
0
 void Start()
 {
     anim          = this.GetComponent <Animator>();
     anim          = this.GetComponent <Animator>();
     targetManager = GetComponent <TargetObjectsManager>();
     movement      = GetComponent <MovementBehaviour>();
 }
Esempio n. 3
0
    /// <summary>
    /// Parse the button in put, and make it work with the grid movement.
    /// </summary>
    void ButtonInput()
    {
        MovementBehaviour.Directions temp     = GetComponent <MovementBehaviour>().directionKey;
        MovementBehaviour            movement = GetComponent <MovementBehaviour>();
        bool tryChange = false;

        if (Input.GetKey(KeyCode.UpArrow))
        {
            temp      = MovementBehaviour.Directions.Up;
            tryChange = true;
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            temp      = MovementBehaviour.Directions.Down;
            tryChange = true;
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            temp      = MovementBehaviour.Directions.Left;
            tryChange = true;
        }
        if (Input.GetKey(KeyCode.RightArrow))
        {
            temp      = MovementBehaviour.Directions.Right;
            tryChange = true;
        }
        if (tryChange)
        {
            movement.TryChangeDirections(temp, true);
        }
    }
Esempio n. 4
0
 public IdleState(
     MovementBehaviour movementBehaviour,
     AnimationBehaviour animationBehaviour)
 {
     _movementBehaviour  = movementBehaviour;
     _animationBehaviour = animationBehaviour;
 }
Esempio n. 5
0
 public static VisualText MakeVisualText(this string obj, MovementBehaviour movement, string fontName = null)
 {
     return(new VisualText(fontName)
     {
         Text = obj
     });
 }
Esempio n. 6
0
    void Awake()
    {
        // Setting up the references.
        charging = GetComponent <ChargingBehaviour>();
        social   = GetComponent <SocialBehaviour>();
        movement = GetComponent <MovementBehaviour>();

        player             = GameObject.FindGameObjectWithTag(GameTags.player);
        baseStation        = GameObject.FindGameObjectWithTag(GameTags.gameController).GetComponent <KonpanionNest>();
        col                = GetComponent <SphereCollider>();
        anim               = GetComponent <Animator>();
        playerAnim         = player.GetComponent <Animator>();
        hash               = GameObject.FindGameObjectWithTag(GameTags.gameController).GetComponent <HashIDs>();
        lastPlayerSighting = GameObject.FindGameObjectWithTag(GameTags.gameController).GetComponent <LastPlayerSighting>();

        checkReachTime = Time.time;
        objectsInReach = new Dictionary <int, Collider>();



        // Set the personal sighting and the previous sighting to the reset position.
        previousSightingTime = -10;
        navDestination       = Vector3.one;
        tickTimer            = 0;
    }
Esempio n. 7
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            MovementBehaviour.UpdateObjectPositions(positionRepository, controller);
            GameRules.CheckGameRules(positionRepository);

            base.Update(gameTime);
        }
    // Update is called once per frame
    void Update()
    {
        getNearbyEnemyShips();
        if (targeting)
        {
            targetEnemyShip();
            targeting = false;
        }
        if (attackTarget != null && !targeting)
        {
            attacking               = true;
            attackBehavior          = new SeekBehaviour(attackTarget.GetComponent <AgentManager>());
            attackBehavior.priority = 10;
            agent.mover.AddBehaviour(attackBehavior);
            agent.target.SetDirectTarget(attackTarget);
        }

        if (attackTarget == null)
        {
            if (attackBehavior != null)
            {
                agent.mover.RemoveBehaviour(attackBehavior);
            }

            attacking = false;
        }
    }
Esempio n. 9
0
 public void Awake()
 {
     chef          = new Chef(startingHappiness);
     body          = GetComponentInParent <Rigidbody>();
     bodyTransform = GetComponentInParent <Transform>().parent;
     movement      = GetComponent <MovementBehaviour>();
     foodDrop      = GetComponent <FoodDropBehaviour>();
 }
Esempio n. 10
0
 void Awake()
 {
     //movement.position = this.transform.position;
     movement = GetComponent <MovementBehaviour>();
     //movespeed = GetComponent<SpeedBehaviour>();
     //movespeed.maxSpeed = _maxSpeed;
     movement.maxSpeed = _maxSpeed;
 }
Esempio n. 11
0
 public void Awake()
 {
     eater         = new Eater(startingHunger);
     body          = GetComponentInParent <Rigidbody>();
     bodyTransform = GetComponentInParent <Transform>().parent;
     movement      = GetComponent <MovementBehaviour>();
     foodEating    = GetComponent <FoodEatingBehaviour>();
 }
        public TopDownCamera(Viewport viewport)
        {
            CurrentViewport = viewport;

            Zoom     = 1.0f;
            Position = new MovementBehaviour();
            Rotation = new RotationBehaviour();
        }
Esempio n. 13
0
    // Use this for initialization
    void Start()
    {
        movement = GetComponent <MovementBehaviour>();
        movement.defaultSpeed = .8f;
        movement.speed        = movement.defaultSpeed;

        SetNewTarget();
    }
Esempio n. 14
0
    private void Awake()
    {
        _audioSource       = GetComponent <AudioSource>();
        _movementBehaviour = GetComponent <MovementBehaviour>();

        EnemyDestroyedOrRemovedEvent = new UnityGameObjectEvent();
        BlownUpEvent = new UnityGameObjectEvent();
    }
Esempio n. 15
0
 public EmptyState(
     Transform owner,
     Transform player,
     MovementBehaviour movement)
 {
     _owner    = owner;
     _player   = player;
     _movement = movement;
 }
Esempio n. 16
0
 public void TurnOn()
 {
     _movingBehaviour = GetComponent <MovementBehaviour>();
     if (_movingBehaviour != null)
     {
         _movingBehaviour.Move();
     }
     StartCoroutine(SawAnimation());
 }
Esempio n. 17
0
    ///<summary>
    ///Sets where to go when not attacking behavior based on whether the creep is a big one or a small one
    ///</summary>
    public void setLocateBehavior()
    {
        if (goToLocation != null)
        {
            agent.target.CmdSetDirectTarget(goToLocation);
        }

        locateBehavior = new SeekBehaviour(agent.target.direct, true);
    }
Esempio n. 18
0
 public ChaseState(
     Transform player,
     MovementBehaviour movementBehaviour,
     VisionSensor visionSensor)
 {
     _player            = player;
     _movementBehaviour = movementBehaviour;
     _visionSensor      = visionSensor;
 }
Esempio n. 19
0
    public void Initialize()
    {
        attack   = GetComponent <AttackBehaviour> ();
        target   = GetComponent <TargetBehaviour> ();
        movement = GetComponent <MovementBehaviour> ();
        evade    = GetComponent <EvadeBehaviour> ();

        individual = GetComponent <Individual> ();
    }
Esempio n. 20
0
 public VisualText(string registeredFontName = null)
 {
     SetRegisteredFontName(registeredFontName);
     Position = new MovementBehaviour();
     Alpha    = new AlphaBehaviour();
     Rotation = new RotationBehaviour();
     Color    = Color.White;
     Scale    = Vector2.One;
 }
Esempio n. 21
0
 // Start is called before the first frame update
 void Start()
 {
     //find objects we need
     m_PlayerShootingBehaviour = FindObjectOfType <ShootingBehaviour>();
     m_PlayerMovementBehaviour = FindObjectOfType <MovementBehaviour>();
     m_PlayerBehaviour         = FindObjectOfType <PlayerCharacter>();
     //set time to 1 when the game starts
     Time.timeScale = 1;
 }
Esempio n. 22
0
        private void Awake()
        {
            _player             = GameObject.FindGameObjectWithTag(Tags.PLAYER).transform;
            _movementBehaviour  = GetComponent <MovementBehaviour>();
            _animationBehaviour = GetComponent <AnimationBehaviour>();
            _visionSensor       = GetComponent <VisionSensor>();

            CreateStages();
        }
Esempio n. 23
0
        private IEnumerator SlowlySetBackOrbit()
        {
            var temp = _target;

            _target = null;
            yield return(new WaitForSeconds(0.2f));

            _rotationVector *= -1;
            StartOrbiting(temp);
        }
Esempio n. 24
0
    void Awake()
    {
        cartMovement        = cart.GetComponent <MovementBehaviour>();
        waypointCoordinates = new Vector3[waypoints.Length];

        for (int i = 0; i < waypoints.Length; i++)
        {
            waypointCoordinates[i] = waypoints[i].position;
        }
    }
Esempio n. 25
0
        public void Initiate()
        {
            _movementBehaviour = GetComponent <MovementBehaviour>();
            var heading = Target.transform.position - transform.position;

            _movementBehaviour.SetVelocity(heading.normalized * _movementBehaviour.MaxVelocity);
            float angle = Mathf.Atan2(_movementBehaviour.Velocity.y,
                                      _movementBehaviour.Velocity.x) * Mathf.Rad2Deg;

            transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
        }
Esempio n. 26
0
 public CatchState(
     Transform owner,
     Transform player,
     AnimationBehaviour animationBehaviour,
     MovementBehaviour movementBehaviour)
 {
     _owner              = owner;
     _player             = player;
     _animationBehaviour = animationBehaviour;
     _movementBehaviour  = movementBehaviour;
 }
Esempio n. 27
0
 private void Awake()
 {
     MovementBehaviour        = GetComponent <MovementBehaviour>();
     ShootingBehaviour        = GetComponent <ShootingBehaviour>();
     _stealthBehaviour        = GetComponent <StealthBehaviour>();
     _takeOverBehaviour       = GetComponent <TakeOverBehaviour>();
     _interActionBehaviour    = GetComponent <InterActionBehavior>();
     HealthBehaviour          = GetComponent <HealthBehaviour>();
     _defendingBehaviour      = GetComponent <DefendingBehaviour>();
     _swithcTakeOverBehaviour = GetComponent <SwitchTakeOverBehaviour>();;
 }
Esempio n. 28
0
 public StrafeState(
     Transform owner,
     Transform player,
     MovementBehaviour movementBehaviour,
     VisionSensor visionSensor)
 {
     _owner             = owner;
     _player            = player;
     _movementBehaviour = movementBehaviour;
     _visionSensor      = visionSensor;
 }
Esempio n. 29
0
    // Called by PatrolManager
    public void StartSquadMoving()
    {
        cartMovement.ChangeDestination(waypointCoordinates);

        foreach (GameObject guard in guards)
        {
            MovementBehaviour guardMovement = guard.GetComponent <MovementBehaviour>();

            guardMovement.ChangeDestination(AdjustPathForGuard(guard));
        }
    }
Esempio n. 30
0
    // Responce for AttackEvent
    public void ReadyForAttack()
    {
        cartMovement.StopMovement();

        foreach (GameObject guard in guards)
        {
            MovementBehaviour guardMovement = guard.GetComponent <MovementBehaviour>();

            guardMovement.StopMovement();
        }
    }
Esempio n. 31
0
    void Awake()
    {
        this.inputController = GameObject.FindGameObjectWithTag("Input").GetComponent<InputController>();
        this.myTransform = GetComponent<Transform>();
        this.lifeBehaviour = GetComponent<LifeBehaviour>();
        this.movementBehaviour = GetComponent<MovementBehaviour>();
        this.animatorBehaviour = GetComponent<AnimatorBehaviour>();

        this.energyBehaviour = new Energy();
        this.lifeBehaviour.life = life; this.lifeBehaviour.currentLife = life;
    }
Esempio n. 32
0
    // Update is called once per frame
    void Update()
    {
        if(FindObjectOfType <DoorSetActive>()){
        if (FindObjectOfType <DoorSetActive>().isActiveAndEnabled == true) {
            if (slowed)
                actualSpeed = speed / slowFactor;
            else
                actualSpeed = speed;

            isPlayerInRange = Physics2D.OverlapCircle (transform.position, aggroRange, playerLayer);

            if (isPlayerInRange && myBehaviour != MovementBehaviour.GroundPatrolling && myBehaviour != MovementBehaviour.FlyingPatrolling) {
                if (target.transform.position.x > transform.position.x) {
                    transform.localScale = new Vector3 (1.0f, 1.0f, 0.0f);
                } else {
                    transform.localScale = new Vector3 (-1.0f, 1.0f, 0.0f);
                }
            }

            switch (myBehaviour) {
            case MovementBehaviour.GroundAggro:

                hasHitWall = Physics2D.OverlapCircle (wallCheckTransform.position, wallCheckRadius, wallCheckLayer);
                thersGround = Physics2D.OverlapCircle (edgeCheckTransform.position, wallCheckRadius, wallCheckLayer);

                if (isPlayerInRange) {
                    if (target.transform.position.x > transform.position.x) {
                        rb2d.velocity = new Vector2 (actualSpeed, rb2d.velocity.y);
                    } else {
                        rb2d.velocity = new Vector2 (-actualSpeed, rb2d.velocity.y);
                    }
                }

                if ((hasHitWall || !thersGround) && !jumping) {
                    jumping = true;
                    rb2d.velocity = new Vector2 (rb2d.velocity.x, jumpPower);
                }

                if (rb2d.velocity.y == 0.0f) {
                    jumping = false;
                }

                break;

            case MovementBehaviour.GroundPatrolling:

                hasHitWall = Physics2D.OverlapCircle (wallCheckTransform.position, wallCheckRadius, wallCheckLayer);
                thersGround = Physics2D.OverlapCircle (edgeCheckTransform.position, wallCheckRadius, wallCheckLayer);

                if (hasHitWall || !thersGround) {
                    moveRight = !moveRight;
                }

                if (moveRight) {
                    transform.localScale = new Vector3 (-1.0f, 1.0f, 1.0f);
                    rb2d.velocity = new Vector2 (actualSpeed, rb2d.velocity.y);
                } else {
                    transform.localScale = new Vector3 (1.0f, 1.0f, 1.0f);
                    rb2d.velocity = new Vector2 (-actualSpeed, rb2d.velocity.y);
                }
                break;

            case MovementBehaviour.GroundSmart:

                isPlayerTooClose = Physics2D.OverlapCircle (transform.position, defensiveRange, playerLayer);
                smartTimer -= Time.deltaTime;
                if (isPlayerTooClose && smartTimer <= 0) {
                    smartTimer = 1;
                    if (target.transform.position.x > transform.position.x) {
                        rb2d.velocity = new Vector2 (-actualSpeed, jumpPower);
                    } else
                        rb2d.velocity = new Vector2 (actualSpeed, jumpPower);
                }
                break;

            case MovementBehaviour.GroundAgile:
                smartTimer -= Time.deltaTime;
                playerProjectile = GameObject.FindGameObjectWithTag ("PlayerAbility");
                if (playerProjectile.transform.position.y < transform.position.y + 1 && playerProjectile.transform.position.y > transform.position.y - 1) {
                    toPlayerProj = playerProjectile.transform.position - transform.position;
                    if (toPlayerProj.magnitude < defensiveRange && smartTimer <= 0) {
                        smartTimer = 2.08f;
                        rb2d.velocity = new Vector2 (rb2d.velocity.x, jumpPower * 2);
                    }
                }
                break;

            case MovementBehaviour.FlyingAggro:

                if (isPlayerInRange) {
                    transform.position = Vector3.MoveTowards (transform.position, target.transform.position, actualSpeed * Time.deltaTime);
                }
                break;

            case MovementBehaviour.FlyingPatrolling:

                transform.position = Vector3.MoveTowards (transform.position, currentWaypoint, actualSpeed * Time.deltaTime);

                if (transform.position == currentWaypoint) {
                    //Debug.Log("Reached waypoint");
                    if (transform.position - startingPosition == waypoint1.localPosition) {
                        //	Debug.Log("Reached waypoint 1");
                        currentWaypoint = waypoint2.position + startingPosition - transform.position;
                    } else if (transform.position - startingPosition == waypoint2.localPosition) {
                        //	Debug.Log("Reached waypoint 2");
                        currentWaypoint = waypoint3.position + startingPosition - transform.position;
                    } else if (transform.position - startingPosition == waypoint3.localPosition) {
                        //	Debug.Log("Reached waypoint 2");
                        currentWaypoint = waypoint4.position + startingPosition - transform.position;
                    } else if (transform.position - startingPosition == waypoint4.localPosition) {
                        //	Debug.Log("Reached waypoint 2");
                        currentWaypoint = waypoint5.position + startingPosition - transform.position;
                    } else if (transform.position - startingPosition == waypoint5.localPosition) {
                        //	Debug.Log("Reached waypoint 2");
                        currentWaypoint = waypoint6.position + startingPosition - transform.position;
                    } else if (transform.position - startingPosition == waypoint6.localPosition) {
                        //	Debug.Log("Reached waypoint 3");
                        currentWaypoint = startingPosition;
                    } else if (transform.position == startingPosition) {
                        //	Debug.Log("Reached starting point");
                        currentWaypoint = waypoint1.position;
                    }
                }

                break;

            case MovementBehaviour.Stunned:

                stunTimer -= Time.deltaTime;
                if (stunTimer <= 0) {
                    myBehaviour = myDefaultBehaviour;
                }
                break;
                }
            }
        }
    }
Esempio n. 33
0
    // Use this for initialization
    void Start()
    {
        startingPosition = transform.position;
        currentWaypoint = waypoint1.position;

        actualSpeed = speed;
        myBehaviour = myDefaultBehaviour;
        target = GameObject.Find("Player");
        rb2d = GetComponent<Rigidbody2D>();
        jumping = false;
        smartTimer = 0;
    }
Esempio n. 34
0
 public void GetStun(float stn)
 {
     //rb2d.velocity = Vector2.zero;
     myBehaviour = MovementBehaviour.Stunned;
     stunTimer = stn;
 }