Наследование: MonoBehaviour
Пример #1
0
    /*
     * public int GetBulletSpeed() {
     *  return IsPlayerBullet() ? playerBulletSpeed : enemyBulletSpeed;
     * }
     */

    void Start()
    {
        followObj = GetComponent <FollowObject>();

        speed        = IsPlayerBullet() ? playerBulletSpeed : enemyBulletSpeed;
        currentSpeed = isFrozen ? 0 : speed;
    }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     followObject           = this.GetComponent <FollowObject>();
     spriteRenderer         = this.GetComponent <SpriteRenderer>();
     myPlayer.playerSet    += playerIsSet;
     spriteRenderer.enabled = false;
 }
Пример #3
0
 void UpdateIntakingInfo(bool isIntaking, bool isIntakingRobotBlue, GameObject intakingRobotHeldBall, GameObject intakingRobotWheel, FollowObject intakingRobotFollowerScript)
 {
     this.isIntakingRobotBlue         = isIntakingRobotBlue;
     this.intakingRobotHeldBall       = intakingRobotHeldBall;
     this.intakingRobotWheel          = intakingRobotWheel;
     this.intakingRobotFollowerScript = intakingRobotFollowerScript;
     this.isIntaking = isIntaking;
 }
Пример #4
0
 void Awake()
 {
     boxCollider2D       = GetComponent <BoxCollider2D>();
     followObject        = GetComponent <FollowObject>();
     followObject.Speed  = MonsterBase.Speed;
     followObject.Target = GameManager.instance.Tank.transform;
     currentHealth       = MonsterBase.Health;
 }
Пример #5
0
 public Run(GameObject _self, GameObject _target, FollowObject _followScript, Rigidbody2D _rb, float _speed)
 {
     self         = _self;
     target       = _target;
     speed        = _speed;
     followScript = _followScript;
     rb           = _rb;
 }
Пример #6
0
 private void Start()
 {
     rb = GetComponent <Rigidbody2D>();
     //collid = GetComponent<Collider2D>();
     animator   = GetComponent <Animator>();
     followObj  = GetComponent <FollowObject>();
     sprenderer = GetComponent <SpriteRenderer>();
 }
Пример #7
0
    // Start is called before the first frame update
    void Start()
    {
        _animationDuration = PositionLerp.keys[PositionLerp.keys.Length - 1].time;

        _followObject = GetComponent <FollowObject>();

        _trans = transform;

        enabled = false;
    }
Пример #8
0
    // Update is called once per frame
    void Update()
    {
        //Check if camera should follow.
        if (Playing)
        {
            objectTime += Time.deltaTime;
            FollowObject followObj = FollowObjects[objectIndex];

            //Is the current time more then the time spent on that FollowObject?
            if (objectTime >= followObj.WaitTime)
            {
                //Take away the WaitTime (This will keep it in time with the physics.
                //If it sets to 0 it will loose difference in time making it desync with the physics.
                objectTime -= followObj.WaitTime;
                objectIndex++;

                //If the objectIndex is larger then the list then just set to the end.
                if (objectIndex >= FollowObjects.Length)
                {
                    ResetCanvas.enabled = true;
                    objectIndex         = FollowObjects.Length - 1;
                }

                //Update object index.
                followObj = FollowObjects[objectIndex];
            }

            //New position variable.
            Vector3 newPosition;

            if (followObj.MovingObject)
            {
                //Set the new position to the current objects position.
                newPosition = followObj.transform.position;
            }
            else
            {
                //Get the current camera position without the offset added on.
                Vector3 cameraFollowPos = (transform.position - CameraOffset);
                Vector3 objectPos       = FollowObjects[objectIndex].transform.position;

                //Calculate time between 0 and 1
                float time = objectTime / followObj.WaitTime;

                //Smooth step the position
                //Creates the illusion of a smooth moving camera.
                newPosition = new Vector3(Mathf.SmoothStep(cameraFollowPos.x, objectPos.x, time),
                                          Mathf.SmoothStep(cameraFollowPos.y, objectPos.y, time),
                                          Mathf.SmoothStep(cameraFollowPos.z, objectPos.z, time));
            }

            //Set cameras position to the new position + the camera offset.
            transform.position = newPosition + CameraOffset;
        }
    }
Пример #9
0
 void ScalePressed()
 {
     if (scaleWidget == null)
     {
         RemoveWidgets();
         scaleWidget = Instantiate(scaleWidgetPrefab, currentObject.transform.position, currentObject.transform.rotation);
         scaleWidget.targetObject = currentObject.transform;
         FollowObject followObj = scaleWidget.gameObject.AddComponent <FollowObject>();
         followObj.Target = currentObject.transform;
     }
 }
Пример #10
0
 // Use this for initialization
 void Start()
 {
     // This script requires a lot of interaction with the follow object script.
     followObjScript = gameObject.GetComponent<FollowObject>();
     if(followObjScript == null)
     {
         Debug.LogError("Error: You must include a Follow Object Script to use Back Away");
     } else {
         // Don't move below the starting position value
         globalYMin = this.transform.position.y;
     }
 }
Пример #11
0
    public void HandleFinalDuel(GameObject winner, GameObject loser, AnimationCurve x, AnimationCurve y)
    {
        //Destroy(BracketLines);
        loserStack.GetComponent <LoserStack>().MakeLoserStack(winner, loser);
        FollowObject fo = this.camera.GetComponent <FollowObject>();

        fo.t = loser.transform;
        AnimationCurve x2 = AnimationCurve.Linear(0f, 0f, 1f, 1f);
        MoveAnimation  ma = loser.GetComponent <MoveAnimation>();

        loser.AddComponent <RotateOverTime>();
        ma.Setup(0.0f, 1.0f, loserStack, x2, x2);
    }
Пример #12
0
    public void PlayEmote(string id)
    {
        if (stickersFactory == null || !stickersFactory.TryGet(id, out GameObject prefab))
        {
            return;
        }

        GameObject emoteGameObject = Instantiate(prefab);

        emoteGameObject.transform.position += transform.position;
        FollowObject emoteFollow = emoteGameObject.AddComponent <FollowObject>();

        emoteFollow.target = transform;
        emoteFollow.offset = prefab.transform.position;
    }
Пример #13
0
    static public FollowObject Create(string root, GameObject toFollow, Transform container, string owner)
    {
        WAKEUP = true;
        FollowObject obj = null;

        obj = (FollowObject)Resources.Load(root, typeof(FollowObject));
        obj = (FollowObject)Instantiate(obj, new Vector3(), Quaternion.identity);
        // obj.HType = hType;
        obj.transform.name = obj.MyId = obj.Rename(obj.transform.name, obj.Id, obj.HType) + " own:" + owner;
        obj.ToFollow       = toFollow;

        if (container != null)
        {
            obj.transform.SetParent(container);
        }
        return(obj);
    }
    private void OnVisualCue(AvatarRenderer.VisualCue cue)
    {
        if (cue != avatarVisualCue || particlePrefab == null)
        {
            return;
        }

        GameObject particles = Instantiate(particlePrefab);

        particles.transform.position = avatarRenderer.transform.position + particlePrefab.transform.position;
        if (followAvatar)
        {
            FollowObject particlesFollow = particles.AddComponent <FollowObject>();
            particlesFollow.target = avatarRenderer.transform;
            particlesFollow.offset = particlePrefab.transform.position;
        }
    }
Пример #15
0
    public void SetActivePOVCamera(Transform transform)
    {
        if (MainCamera != null)
        {
            MainCamera.gameObject.SetActive(false);
        }

        if (POVCamera != null)
        {
            POVCamera.gameObject.SetActive(true);
            FollowObject follow = POVCamera.GetComponent <FollowObject>();
            if (follow != null)
            {
                follow.SetFollow(transform);
            }
        }
    }
Пример #16
0
    private void AddressNewCurrentRoot(bool hide)
    {
        //means was used already once . could have this object we are looking for spawnerd
        if (_current != null)
        {
            _current = null;
        }

        if (_allPersonalObjects.ContainsKey(_currentRoot))
        {
            _current = _allPersonalObjects[_currentRoot];

            //for Docker and HeavyLoader so it doesnt show this when on Dock
            if (_person.Work != null &&
                (_person.Work.HType == H.Dock) &&
                //(_person.Work.HType == H.Dock || _person.Work.HType == H.HeavyLoad) &&
                _person.DistanceToWorkSpawnPoint() < 0.1f)
            {
            }
            //for hammer so is shown
            else
            {
                Show();
            }

            CheckIfHide(hide);
            return;
        }

        if (string.IsNullOrEmpty(_currentRoot))
        {
            return;
        }

        _current = FollowObject.Create(_currentRoot, _currentPoint, //Program.PersonObjectContainer.transform,
                                       _currentPoint.transform,
                                       _person.MyId);

        _current.transform.rotation = _currentPoint.transform.rotation;
        _current.transform.position = _currentPoint.transform.position;

        _allPersonalObjects.Add(_currentRoot, _current);
        CheckIfHide(hide);
    }
Пример #17
0
    void Kill()
    {
        SineMovement sm = GetComponent <SineMovement>();

        if (sm != null)
        {
            sm.enabled = false;
        }

        StraightMovement strm = GetComponent <StraightMovement>();

        if (strm != null)
        {
            strm.enabled = false;
        }

        FollowObject fo = GetComponent <FollowObject>();

        if (fo != null)
        {
            fo.enabled = false;
        }

        CircularMovement cm = GetComponent <CircularMovement>();

        if (cm != null)
        {
            cm.enabled = false;
        }

        //Disable the renderer and the Collider
        GetComponent <SpriteRenderer>().enabled = false;
        GetComponent <Collider2D>().enabled     = false;

        if (m_particle != null)
        {
            m_particle = ObjectPool.Instantiate(m_particle, transform.position, transform.rotation);
            StartCoroutine(KillAnimation());
        }
        else
        {
            ObjectPool.Kill(gameObject);
        }
    }
Пример #18
0
        public async static Task <FollowingsObject> GetFollowingsOfUser(int userId)
        {
            dynamic dynFollowingsObj = await GetResultFromURL(USER_PATH + userId + "/following.json");

            FollowingsObject followingsObj = new FollowingsObject();

            followingsObj.Count = dynFollowingsObj.count;

            ObservableCollection <FollowObject> followings = new ObservableCollection <FollowObject>();

            foreach (var following in dynFollowingsObj.followers)
            {
                followings.Add(FollowObject.fromDynamic(following));
            }

            followingsObj.Followings = followings;

            return(followingsObj);
        }
Пример #19
0
    IEnumerator bornCd()
    {
        yield return(new WaitForSeconds(0.01f));

        maincamera = GameObject.Find("CameraController").GetComponent <Camera>();
        FollowObject followObject = GameObject.Find("Camera").GetComponent <FollowObject>();

        followObject.FindCameraTarget();
        transform.position = new Vector3(360f, 0f, 360f);
        transform.Find("Root").transform.Rotate(new Vector3(45f, 0, 0));
        input              = GameObject.Find("GameManager").GetComponent <InputController>();
        input.OnLeftClick += Interact;

        //Debug.Log("root rotation:"+transform.Find("Root").transform.rotation);
        rd         = GetComponent <Rigidbody>();
        healthText = GameObject.Find("PlayerHealthText").GetComponent <TextMeshProUGUI>();
//       Debug.Log(healthText.name);
        healthText.text = health.ToString();
    }
Пример #20
0
 public void reset()
 {
     currentHealth = maxHealth;
     currentHealth = maxHealth;
     if (healthBarGameObject != null)
     {
         GameObject bar = ObjectPool.instance.GetObjectForType(healthBarGameObject);
         if (bar != null)
         {
             FollowObject follow = bar.GetComponent <FollowObject>();
             if (follow != null)
             {
                 follow.setFollowing(this.gameObject);
             }
             healthBar = bar.GetComponent <BarControl>();
         }
     }
     if (healthBar != null)
     {
         healthBar.setPercent(currentHealth, maxHealth);
     }
 }
Пример #21
0
    private void AddressNewCurrentRoot(bool hide)
    {
        //means was used already once . could have this object we are looking for spawnerd
        if (_current != null)
        {
            _current = null;
        }

        if (_allPersonalObjects.ContainsKey(_currentRoot))
        {
            _current = _allPersonalObjects[_currentRoot];

            //for hammer so is shown
            Show();

            CheckIfHide(hide);
            return;
        }

        if (string.IsNullOrEmpty(_currentRoot))
        {
            return;
        }

        //ResetPersonPosition();

        _current = FollowObject.Create(_currentRoot, _currentPoint, //Program.PersonObjectContainer.transform,
                                       _currentPoint.transform,
                                       _person.MyId);

        _current.transform.rotation = _currentPoint.transform.rotation;
        _current.transform.position = _currentPoint.transform.position;

        _allPersonalObjects.Add(_currentRoot, _current);
        CheckIfHide(hide);

        //ReloadPersonPosition();
    }
Пример #22
0
    /*IEnumerator DamagedAnimation() {
     *  for (float f = 0; f <= 1; f += 0.2f) {
     *      m_renderer.color = new Color(215f / 255 * f, 63f / 255 * f, 63f / 255 * f);
     *      Debug.Log("CHANGE: " + m_renderer.color.r + ", " + m_renderer.color.g + ", " + m_renderer.color.b);
     *      yield return new WaitForSeconds(0.1f);
     *  }
     *
     *  for (float f = 1; f >= 0; f -= 0.2f) {
     *      m_renderer.color = new Color(215f / 255 * f, 63f / 255 * f, 63f / 255 * f);
     *      Debug.Log("CHANGE BACK: " + m_renderer.color.r + ", " + m_renderer.color.g + ", " + m_renderer.color.b);
     *      yield return new WaitForSeconds(0.1f);
     *  }
     * }*/

    void Kill()
    {
        SineMovement sm = GetComponent <SineMovement>();

        if (sm != null)
        {
            sm.enabled = false;
        }

        StraightMovement strm = GetComponent <StraightMovement>();

        if (strm != null)
        {
            strm.enabled = false;
        }

        FollowObject fo = GetComponent <FollowObject>();

        if (fo != null)
        {
            fo.enabled = false;
        }

        CircularMovement cm = GetComponent <CircularMovement>();

        if (cm != null)
        {
            cm.enabled = false;
        }

        //Disable the renderer and the Collider
        GetComponent <SpriteRenderer>().enabled = false;
        GetComponent <Collider2D>().enabled     = false;

        m_particle.Play();
        StartCoroutine(KillAnimation());
    }
Пример #23
0
    /// <summary>
    /// Use this for initialization
    /// </summary>
    void Start()
    {
        if ((songNum == 1 && mainSong1Clip != null) || (songNum == 2 && mainSong2Clip != null))
        {
            mainSongSource = gameObject.AddComponent<AudioSource>();
            mainSongSource.clip = ((songNum == 1) ? mainSong1Clip : mainSong2Clip);
            mainSongSource.playOnAwake = true;
            mainSongSource.loop = true;
        }
        if((songNum == 1 && intro1Clip != null) || (songNum == 2 && intro2Clip != null))
        {
            introSource = gameObject.AddComponent<AudioSource>();
            introSource.clip = ((songNum == 1) ? intro1Clip : intro2Clip);
            introSource.playOnAwake = true;
            introSource.loop = true;
            introSource.volume = introVolume;
        }

        overlaySources = new List<AudioSource>();
        foreach(AudioClip overlay in ((songNum == 1) ? overlay1Clips : overlay2Clips))
        {
            AudioSource source = gameObject.AddComponent<AudioSource>();
            source.clip = overlay;
            source.playOnAwake = true;
            source.loop = true;
            source.volume = 0;
            overlaySources.Add(source);
        }
        currentOverlay = -1;

        // Needed to play music once the camera picks up an object
        cameraFollowScript = Camera.main.GetComponent<FollowObject> ();

        if(playIntro)
        {
            StartIntroMusic();
        } else
        {
            StartBkgMusic();
        }
        hasStartedBkgMusic = !playIntro;
    }
Пример #24
0
 private void Start()
 {
     animController = gameObject.GetComponent <Animator>();
     mainCamFollow  = GameObject.FindWithTag("MainCamera").GetComponent <FollowObject>();
     playerMovement = GetComponent <Movement>();
 }
 // Use this for initialization
 void Start()
 {
     viewportCam = Camera.main;
     cameraFollowScript = viewportCam.GetComponent<FollowObject> ();
     loadSoundManager ();
 }
Пример #26
0
 internal void Reset()
 {
     Hide();
     _currentAni = "";
     _current    = null;
 }