Exemple #1
0
        // move to child
        private void CreateFly(GameObject _blockGameObject, int _index)
        {
            GameObject prefab =
                Mgr <CatProject> .Singleton.prefabList.GetItem(m_flyPrefabName);

            _blockGameObject.ForceUpdateAbsTransformation();
            //float randy = (float)m_rand.NextDouble() * m_blockWidth;
            Serialable.BeginSupportingDelayBinding();
            GameObject fly = prefab.DoClone() as GameObject;

            fly.Position = _blockGameObject.AbsPosition +
                           new Vector3(0.0f, m_flyHeight, 0.0f);

            Mgr <Scene> .Singleton._gameObjectList.AddGameObject(fly);

            ButterflyController bfc =
                fly.GetComponent(typeof(ButterflyController).ToString())
                as ButterflyController;

            if (bfc != null)
            {
                bfc.HorizontalVelocity += (float)(m_rand.NextDouble() * 2.0f - 1.0f)
                                          * m_flyHorizontalVelocityBias;
            }
            Serialable.EndSupportingDelayBinding();
        }
Exemple #2
0
        public override void Update(int timeLastFrame)
        {
            base.Update(timeLastFrame);

            if (m_sucess)
            {
                ButterflyController bfc = m_gameObject.GetComponent(
                    typeof(ButterflyController).ToString()) as ButterflyController;
                if (bfc != null)
                {
                    Vector3 delta = m_player.AbsPosition + new Vector3(-0.25f, 0.15f, 0)
                                    - m_gameObject.AbsPosition;
                    m_gameObject.Position += new Vector3(0.01f * delta.X, delta.Y * 0.001f, 0);
                }
            }
        }