Пример #1
0
    /// <summary>
    /// Sets movement state to wander.
    /// </summary>
    /// <param name="room"></param>
    public void StartWandering(Room room)
    {
        var followState  = new FollowTarget(Character, GameController.Instance.Player);
        var lookForState = new LookForCharacter(Character, GameController.Instance.Player, room, followState);

        CurrentState = lookForState;
    }
Пример #2
0
        public override void Update()
        {
            new EntityQuery()
            .With <FollowTarget>()
            .ForEach(obj =>
            {
                FollowTarget follow = obj.GetECSComponent <FollowTarget>();

                //calming down the enemy
                if (follow.HasBeenCalmDown)
                {
                    obj.transform.position = GameMananger.RandomNavmeshLocation(400f, obj);
                    obj.GetECSComponent <TrailRenderer>().UnityComponent.Clear();

                    follow.HasBeenCalmDown = false;

                    EntityActionBuffer.Instance.ApplyComponentChanges(obj, follow);
                }

                //we pick a new target
                PickNewTarget(obj, follow);

                //We see if the target is dead or not
                KillTarget(obj, follow);

                if (follow.Target != null)
                {
                    obj.GetECSComponent <NavMeshAgent>().UnityComponent.SetDestination(follow.Target.transform.position);
                }
            });
        }
Пример #3
0
 // Use this for initialization
 void Start()
 {
     //reference
     score  = FindObjectOfType <ScoreScript>();
     health = FindObjectOfType <HealthScript>();
     camera = FindObjectOfType <FollowTarget>();
 }
Пример #4
0
 private void PickNewTarget(GameObject obj, FollowTarget follow)
 {
     //only pick new target once or if the new target want to do a Vendetta
     //it will chase it down until he is dead
     if (follow.Target == null || follow.Target.GetECSComponent <Vendetta>().WantToDoVendetta)
     {
         float dist = float.MaxValue;
         new EntityQuery()
         .With <Score>()
         .With <Vendetta>()
         .ForEach(objToFollow =>
         {
             //only pick green pecsman
             Vendetta vendetta = objToFollow.GetECSComponent <Vendetta>();
             if (!vendetta.WantToDoVendetta)
             {
                 if (Vector3.Distance(obj.transform.position, objToFollow.transform.position) < dist)
                 {
                     follow.Target = objToFollow;
                     dist          = Vector3.Distance(obj.transform.position, objToFollow.transform.position);
                 }
             }
         });
         EntityActionBuffer.Instance.ApplyComponentChanges(obj, follow);
     }
 }
Пример #5
0
 public override void StartAction()
 {
     isDone      = false;
     orbitStatus = 0;
     SwitchTarget();
     followTarget = new FollowTarget(dog, rosie, offset, true, 0.2f);
 }
Пример #6
0
    protected override void Affect(GameObject target)
    {
        base.Affect(target);

        _follow     = target.GetComponent <FollowTarget>();
        _controller = target.GetComponent <HeroController>();
        _rb         = target.GetComponent <Rigidbody2D>();

        // Disable movement code
        if (_follow != null)
        {
            _follow.enabled = false;
        }
        if (_controller != null)
        {
            _controller.enabled = false;
        }

        if (_rb != null && source != null)
        {
            // Add force relative to source
            Vector2 dir = source.transform.up;
            dir.Normalize();

            _rb.velocity += dir * Force;
        }
    }
Пример #7
0
        private void Fire()
        {
            // Set the fired flag so only Fire is only called once.
            m_Fired = true;

            // Create an instance of the shell and store a reference to it's rigidbody.
            Rigidbody shellInstance =
                Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as Rigidbody;

            // Set the shell's velocity to the launch force in the fire position's forward direction.
            shellInstance.velocity = m_CurrentLaunchForce * m_FireTransform.forward;
            FollowTarget shellFT = shellInstance.GetComponent <FollowTarget>();

            if (shellFT != null)
            {
                shellFT.Target   = target;
                shellFT.Velocity = m_CurrentLaunchForce;
            }

            // Change the clip to the firing clip and play it.
            m_ShootingAudio.clip = m_FireClip;
            m_ShootingAudio.Play();

            // Reset the launch force.  This is a precaution in case of missing button events.
            m_CurrentLaunchForce = m_MinLaunchForce;
        }
Пример #8
0
 void Awake()
 {
     GetComponent <SpriteRenderer>().enabled = false;
     transform.GetChild(0).GetComponent <SpriteRenderer>().enabled = false;
     t     = Camera.main.GetComponent <FollowTarget>();
     Panel = GameObject.Find("Canvas").transform.GetChild(1).GetComponent <Image>();
 }
Пример #9
0
 public override void OnInit()
 {
     base.OnInit();
     cameraGO     = Camera.main.gameObject;
     cameraAnim   = cameraGO.GetComponent <Animator>();
     followTarget = cameraGO.GetComponent <FollowTarget>();
 }
Пример #10
0
        private void Awake()
        {
            FollowTarget = GetComponent <FollowTarget>();

            _viewer = ViewerManager.Instance.AcquireViewer <ServerSpectatorViewer>();
            if (null != _viewer)
            {
                _viewer.Initialize(this);
            }

            InputManager.Instance.Controls.game.pause.performed += OnPause;

            InputManager.Instance.Controls.game.moveforward.started    += OnMoveForward;
            InputManager.Instance.Controls.game.moveforward.performed  += OnMoveForwardStop;
            InputManager.Instance.Controls.game.movebackward.started   += OnMoveBackward;
            InputManager.Instance.Controls.game.movebackward.performed += OnMoveBackwardStop;
            InputManager.Instance.Controls.game.moveleft.started       += OnMoveLeft;
            InputManager.Instance.Controls.game.moveleft.performed     += OnMoveLeftStop;
            InputManager.Instance.Controls.game.moveright.started      += OnMoveRight;
            InputManager.Instance.Controls.game.moveright.performed    += OnMoveRightStop;
            InputManager.Instance.Controls.game.jump.started           += OnMoveUp;
            InputManager.Instance.Controls.game.jump.performed         += OnMoveUpStop;
            InputManager.Instance.Controls.game.movedown.started       += OnMoveDown;
            InputManager.Instance.Controls.game.movedown.performed     += OnMoveDownStop;

            InputManager.Instance.Controls.game.look.started   += OnLook;
            InputManager.Instance.Controls.game.look.performed += OnLook;
            InputManager.Instance.Controls.game.look.canceled  += OnLookStop;
        }
 public void OnEnable()
 {
     player             = GameObject.FindWithTag("Player");
     camera             = GameObject.Find("Main Camera");
     followTargetScript = camera.GetComponent <FollowTarget>();
     oldOffset          = followTargetScript.offset;
 }
Пример #12
0
    private void SpawnCars()
    {
        for (int i = 0; i < aiCarCount; i++)
        {
            GameObject aiCarParent = new GameObject("AICar" + i);
            aiCarParent.transform.parent = transform;

            GameObject car = Instantiate(AICar, spawningPoints.GetSpawnPoint(), Quaternion.identity);
            car.transform.parent = aiCarParent.transform;

            GameObject ball = Instantiate(AICarBall);
            car.GetComponent <CarAIController>().Ball       = ball.transform;
            ball.GetComponent <BallMovement>().ballPosition = car.transform.Find("BallPosition");
            ball.transform.position = ball.GetComponent <BallMovement>().ballPosition.position;
            ball.GetComponent <BallCollider>().IsThisAIBall = true;
            ball.transform.parent = aiCarParent.transform;

            // positioning canvas does not work in editor, works in build
            GameObject canvas = Instantiate(AICarCanvas, new Vector3(car.transform.position.x, car.transform.position.y + 2, car.transform.position.z), Quaternion.Euler(45, -90, 0));
            canvas.GetComponent <CarUIController>().isThisCanvasAI = true;
            FollowTarget followTarget = canvas.GetComponent <FollowTarget>();
            followTarget.Target  = car.transform;
            followTarget.enabled = true;
            canvas.transform.SetParent(aiCarParent.transform);

            GameObject     line           = Instantiate(AILine, car.transform.position, Quaternion.identity);
            LineController lineController = line.GetComponent <LineController>();
            lineController.Car    = car.transform;
            lineController.Ball   = ball.transform;
            line.transform.parent = aiCarParent.transform;

            car.GetComponent <CarAIController>().AICarNumber = i;
        }
    }
Пример #13
0
 // Start is called before the first frame update
 void Start()
 {
     health        = GetComponent <HealthController>();
     health.OnDie += HandleDeath;
     target        = GetComponent <FollowTarget>();
     collider      = GetComponent <Collider2D>();
 }
Пример #14
0
 // Use this for initialization
 void Awake()
 {
     _effect = GetComponent< BonusEffect > ();
     _effect.enabled = false;
     _follow = GetComponent< FollowTarget > ();
     _follow.enabled = false;
 }
Пример #15
0
        /// <summary>
        /// Determines if the target is valid
        /// </summary>
        /// <returns>A CustomPhysicsHit result of a Line Cast to the target, or a default one if the target is invalid</returns>
        protected virtual MatrixManager.CustomPhysicsHit ValidateTarget()
        {
            if (FollowTarget != null)
            {
                if (mobAI.IsDead == false && mobAI.IsUnconscious == false)
                {
                    var followLivingBehaviour = FollowTarget.GetComponent <LivingHealthMasterBase>();
                    if (followLivingBehaviour != null)
                    {
                        if (followLivingBehaviour.IsDead)
                        {
                            FollowTarget = null;
                        }
                    }

                    //Continue if it still exists and is in range
                    if (FollowTarget != null && TargetDistance() < TetherRange)
                    {
                        Vector3 dir     = (Vector3)(TargetTile.WorldPositionServer - OriginTile.WorldPositionServer).Normalize() / 1.5f;
                        var     hitInfo = MatrixManager.Linecast(OriginTile.WorldPositionServer + dir,
                                                                 LayerTypeSelection.Windows | LayerTypeSelection.Grills, checkMask, TargetTile.WorldPositionServer);

                        if (hitInfo.ItHit)
                        {
                            return(hitInfo);
                        }
                    }
                }
            }

            FollowTarget = null;
            Deactivate();
            return(new MatrixManager.CustomPhysicsHit());
        }
Пример #16
0
 // Start is called before the first frame update
 void Start()
 {
     xx.SetActive(false);
     SkillButtonMzz    = false;
     UsingC            = false;
     tagbool           = false;
     redtimerbool      = false;
     yunshitingzhibool = false;
     text.SetActive(false);
     timerbool       = false;
     yellowCtr       = false;
     ChongdongBool   = false;
     TimemachineBool = false;
     UsingChange     = false;
     Gate.SetActive(false);
     Miaozhun.SetActive(false);
     UsingMz = true;
     Mz.SetActive(true);
     SkillChoose   = Skills.none;
     SkillButtonMz = true;
     UsingChange2  = false;
     FuChi.SetActive(false);
     Player = GetComponent <FollowTarget>();
     newtag = GameObject.FindGameObjectWithTag("Player");
 }
Пример #17
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("enemyCollide") || other.gameObject.CompareTag("animalRoot") || other.gameObject.CompareTag("animalCollide"))
     {
         if (this.doneStick)
         {
             return;
         }
         arrowStickToTarget arrowStickToTarget = other.GetComponent <arrowStickToTarget>();
         if (arrowStickToTarget == null)
         {
             arrowStickToTarget = other.GetComponentInChildren <arrowStickToTarget>();
         }
         if (arrowStickToTarget)
         {
             Transform transform = arrowStickToTarget.returnNearestJoint(base.transform);
             if (transform)
             {
                 FollowTarget followTarget = base.gameObject.AddComponent <FollowTarget>();
                 followTarget.target         = transform;
                 followTarget.offset         = (base.transform.position - transform.position) / 3.5f;
                 followTarget.followRotation = true;
                 CapsuleCollider component = base.transform.GetComponent <CapsuleCollider>();
                 if (component)
                 {
                     component.isTrigger = true;
                 }
                 base.GetComponent <Rigidbody>().isKinematic = true;
                 this.doneStick = true;
                 UnityEngine.Object.Destroy(this);
             }
         }
     }
 }
 // Use this for initialization
 void Start()
 {
     pE    = GetComponent <PuzzleEvents>();
     floor = GameObject.Find("Floor").GetComponent <Floor>();
     floor.setAllTilesVisibility(false);
     myCoroutine = StartCoroutine(spawnMoles());
     myTarget    = Instantiate(target);
 }
Пример #19
0
    // ------------------------------------------------------- //
    //  Initial functions
    // ------------------------------------------------------- //
    void Init()
    {
        AreaGameObject = Instantiate(AreaPrefab, Vector3.zero, Quaternion.identity);

        GameCamera = FindObjectOfType <FollowTarget>() as FollowTarget;

        AreaController = AreaGameObject.GetComponent <AreaController>();
    }
Пример #20
0
 /// <summary>
 /// Awake this instance.
 /// </summary>
 void Awake()
 {
     espada = this;
     if (!target)                                      //If dont have a target
     {
         target = PlayerStatus.playerStatus.transform; //than the target is the player
     }
 }
Пример #21
0
 private void SetupCameraFollow()
 {
     cameraFollower = Camera.main.GetComponent <FollowTarget>();
     if (cameraFollower != null)
     {
         cameraFollower.target = this.transform;
     }
 }
Пример #22
0
 public override void OnInit()
 {
     Debug.Log("--wangzhi--有被调用到吗--");
     cameraGo     = Camera.main.gameObject;
     cameraAnim   = cameraGo.GetComponent <Animator>();
     followTarget = cameraGo.GetComponent <FollowTarget>();
     Debug.Log(followTarget);
 }
Пример #23
0
 public override void OnInit()
 {
     cameraGO = Camera.main.gameObject;
     TimeLine = GameObject.Find("TimeLine");
     cameraGO.SetActive(false);
     TimeLine.SetActive(true);
     followTarget = cameraGO.GetComponent <FollowTarget>();
 }
Пример #24
0
 public override void OnInit()
 {
     cameraGo             = Camera.main.gameObject;
     followTarget         = cameraGo.GetComponent <FollowTarget>();
     anim                 = cameraGo.GetComponent <Animator>();
     anim.enabled         = true;
     followTarget.enabled = false;
 }
Пример #25
0
 void Awake()
 {
     Resources.UnloadUnusedAssets();
     GC.Collect();
     GetComponent <SpriteRenderer>().enabled = false;
     transform.GetChild(0).GetComponent <SpriteRenderer>().enabled = false;
     t     = Camera.main.GetComponent <FollowTarget>();
     Panel = GameObject.Find("Canvas").transform.GetChild(0).GetComponent <Image>();
 }
Пример #26
0
 // Constructor
 public CameraInfo(GameObject cam)
 {
     gameObject = cam;
     transform = cam.transform;
     rigidbody = cam.GetComponent<Rigidbody> ();
     camera = cam.GetComponent<Camera> ();
     followScript = cam.GetComponent<FollowTarget> ();
     introScript = cam.GetComponent<ExitIntro>();
 }
Пример #27
0
 // Start is called before the first frame update
 void Start()
 {
     //rb = GetComponent<Rigidbody2D>();
     //rb.angularVelocity = Random.Range(0,10)*Speed;
     PickUp = GameObject.Find("Player").GetComponent <Skill>();
     follow = GameObject.Find("Player").GetComponent <FollowTarget>();
     KCtr   = false;
     tooltr = false;
 }
Пример #28
0
 private void Start()
 {
     if (Player == null)
     {
         Player = GameObject.FindGameObjectWithTag("Player");
     }
     followTarget        = GetComponent <FollowTarget>();
     followTarget.Target = Player;
 }
Пример #29
0
    private void OnCollisionEnter(Collision other)
    {
        FollowTarget followTarget = base.gameObject.AddComponent <FollowTarget>();

        followTarget.target = other.transform;
        followTarget.offset = base.transform.position - other.transform.position;
        base.GetComponent <Rigidbody>().isKinematic = true;
        UnityEngine.Object.Destroy(this);
    }
Пример #30
0
    void CompleteFollow()
    {
        var completeFunc = currentFollowTarget.onComplete;

        currentFollowTarget = null;

        completeFunc?.Invoke();

        UpdateState();
    }
Пример #31
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        FollowTarget tar = (FollowTarget)target;

        if (GUILayout.Button("Apply"))
        {
            tar.Setup();
        }
    }
Пример #32
0
    private void Start()
    {
        follow = gameObject.AddComponent <FollowTarget>();
        back   = gameObject.AddComponent <ReturnMove>();

        follow.Init(AI, target, speed, attackRange - 1);
        back.init(AI, spawnPos, speed);
        damageCheck = transform.GetChild(0).gameObject;
        anim.SetInteger("state", 0);
    }
Пример #33
0
	void Start () {
        if (!isLocalPlayer)
        {
            this.enabled = false;
        }
        sceneCameraGO = Camera.main.gameObject;
        sceneCameraFT = sceneCameraGO.GetComponent<FollowTarget>();
        sceneCameraFT.Target = gameObject;
        EatableObjects.Add(this);
        Respawn();
	}
Пример #34
0
    void Awake()
    {
        this.controller = GetComponent<ParticlesController>();
        this.follow = new FollowTarget(this);
        this.noTarget = new NoTarget(this);
        this.gameObject.SetActive(false);

        damageRates = new Dictionary<ArmorType, float>();
        damageRates.Add(ArmorType.Light, LightArmorDamageRate);
        damageRates.Add(ArmorType.Medium, MediumArmorDamageRate);
        damageRates.Add(ArmorType.Heavy, HeavyArmorDamageRate);
    }
Пример #35
0
 void Spawn()
 {
     // Instantiate a random enemy.
     int enemyIndex = Random.Range(0, enemies.Length);
     enemy = (GameObject)Instantiate(enemies[enemyIndex], transform.position, transform.rotation);
     eScript = enemy.GetComponent<Enemy>();
     enemyKill =(GameObject) Instantiate(enemiesKill[enemyIndex], transform.position, transform.rotation);
     fScript = enemyKill.GetComponent<FollowTarget> ();
     eScript.target = enemyKill.transform;
     fScript.target = enemy.transform;
     // Play the spawning effect from all of the particle systems.
     foreach(ParticleSystem p in GetComponentsInChildren<ParticleSystem>())
     {
         p.Play();
     }
 }
Пример #36
0
		private DrawingColor drawingColorComp;//drawing color

		//Use this for Initialization
		void Start ()
		{
				fontSizeType = FontSizeType.PEN;
				fontSize = FontSize.MEDIUM;
				selectedTool = SelectedTool.PEN;
				lineColor = new Color (0, 147, 68, 100) / 255.0f;
				prevColor = lineColor;
				drawingMaterial = GameObject.Find ("green (Drawing Level)").GetComponent<DrawingColor> ().drawingMaterial;
				previousMaterial = drawingMaterial;

				if (middleCam == null) {
						middleCam = GameObject.FindGameObjectWithTag ("MiddleCam").GetComponent<Camera> ();//setting up middle camera reference
				}

				if (drawResizerOb == null) {
						drawResizerOb = GameObject.Find ("Draw-Resizer (Drawing Level)");
				}

				if (toolsAnimator == null) {
						toolsAnimator = GameObject.Find ("Tools").GetComponent<Animator> ();
				}

				if (brushObFollowTarget == null) {
						brushObFollowTarget = GameObject.Find ("brush (Drawing Level)").GetComponent<FollowTarget> ();
				}

				if (deleteObFollowTarget == null) {
						deleteObFollowTarget = GameObject.Find ("eraser (Drawing Level)").GetComponent<FollowTarget> ();
				}

				if (penObFollowTarget == null) {
						penObFollowTarget = GameObject.Find ("pencil (Drawing Level)").GetComponent<FollowTarget> ();
				}

				if (colorsWheelControllerComp == null) {
						colorsWheelControllerComp = GameObject.Find ("ColorsWheel (Drawing Level)").GetComponent<ColorsWheelController> ();
				}
	
				drawResizerBackground = drawResizerOb.transform.Find ("draw-resizer-background (Drawing Level)").gameObject;
				SetDrawResizerColor ();
				SetFontSize ();
		}
Пример #37
0
    private float yPosition; //wanted Y position

    #endregion Fields

    #region Methods

    /// <summary>
    /// Awake this instance.
    /// </summary>
    void Awake()
    {
        espada = this;
        if (!target)//If dont have a target
            target = PlayerStatus.playerStatus.transform;//than the target is the player
    }
 // Use this for initialization
 void Start()
 {
     NotificationCenter.DefaultCenter().AddObserver(this, "ReceiveDamage");
     followTarget = GetComponent<FollowTarget>();
 }
Пример #39
0
    private Vector3 velocity = Vector3.zero; //A reference value used by SmoothDamp that tracks this object velocity
	
    void Awake()
    {
        follow = this;
    }
Пример #40
0
 private void Awake()
 {
     followTarget = gameObject.GetComponent<FollowTarget> ();
     pinchZoom = gameObject.GetComponent<PinchZoom> ();
 }