Exemplo n.º 1
0
    // Use this for initialization
    void Start () {

        clock = GameObject.Find("SimpleClock");
        clock.SetActive(false); 
        anim = GetComponent<tk2dSpriteAnimator>();

}
Exemplo n.º 2
0
    IEnumerator BeginAttack()
    {
        direction facing = FindDirection();
        ChooseAttackAnimation(facing);

        Vector3 posDifference = Player.position - Zombie.position;

        yield return new WaitForSeconds(0.1f);
        if(_state.curState != ZombieSM.ZombieState.Attack){
            yield break;
        }

        if(posDifference.x < 0){	// Left Attack
            Attack = (Transform)Instantiate(LeftAttack, Player.position, Quaternion.identity);
        }
        else{						// RightAttack
            Attack = (Transform)Instantiate(RightAttack, Player.position, Quaternion.identity);
        }
        Attack.transform.position += new Vector3(0, 0, -1);
        Attack.parent = transform;
        AttackAnim = Attack.GetComponent<tk2dSpriteAnimator>();

        PlayRandomAttackSound();
        AttackAnim.Play();
        _timeSinceLastAttack = Time.time + _attackDelay;				// Delays attack
        StartCoroutine(RemoveAttackAnimation());						// Remove attack animation when finished
        //print ("between 2 coroutines");
        StartCoroutine(MovementPause(1f));								// FIX, stop when out of detection range, but in chase mode.
    }
Exemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     rb = GetComponent<Rigidbody2D>();
     audios = GetComponent<AudioSource>();
     target = GameObject.Find("test_player_3");
     anim = GetComponent<tk2dSpriteAnimator>();
 }
Exemplo n.º 4
0
    // Throwing animation takes priority over all others
    public void HandleMovementAnimations(PlayerMovement.Movement m)
    {
        if (anim == null) anim = GetComponent<tk2dSpriteAnimator>();
        string clip;

        // if we're ready to throw again and we pushed throw button
        if (!throwWait && isThrowing)
        {
            clip = "throw";
            anim.AnimationCompleted = ThrowCompleteDelegate;
            anim.AnimationEventTriggered = SpawnDaggerDelegate;
            throwWait = true;
            anim.Play(clip);
        }
        else if (!throwWait) // we're not mid throw animation so run other animations
        {
            if (m.jumping || m.inAir) clip = "jump";
            else if (m.moveHorizontal) clip = "walk";
            else clip = "still";
            if (prevRemoteClip != clip)
            {
                prevRemoteClip = clip;
                anim.Play(clip);
            }
        }
    }
Exemplo n.º 5
0
 void Handle_FishAniStop(tk2dSpriteAnimator sprAni, tk2dSpriteAnimationClip aniClip)
 {
     if (mFish != null && mFish.Attackable)
     {
         mFish.AniSprite.PlayFrom(mOriginClip,0F);
     }
 }
 // done breathing fire, just walk again
 void FireCompleteDelegate(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip)
 {
     if(clip.name.Equals("Fire"))
     {
         anim.Play("Walk");
     }
 }
    void FlameOnDelegate(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip, int frameNumber)
    {
        if(clip.GetFrame(frameNumber).eventInfo.Equals("FlameOn"))
        {
            string fireTag = fireHitObject.tag;

            if (fireTag.Equals("Throwable"))
            {
                Vector3 position = fireHitObject.transform.position;
                position.z = charcoalParticleEffect.transform.position.z;

                // KILL THE PEASANTS
                Destroy(fireHitObject);

                // BURNINATE THE PEASANTS (particle effects)
                ParticleSystem localCharcoal = GameObject.Instantiate(charcoalParticleEffect, position, charcoalParticleEffect.transform.rotation) as ParticleSystem;
                localCharcoal.Play();
            }
            else if (fireTag.Equals("Player"))
            {
                // TODO: tell player to get bumped
            }
        }

        if(clip.GetFrame(frameNumber).eventInfo.Equals("DragonFootStep"))
        {
            AudioSource.PlayClipAtPoint(footSteps[Random.Range( 0, footSteps.Count )], transform.position);
        }
    }
Exemplo n.º 8
0
 void Handle_YunMuAnimating(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip, int frameNum)
 {
     tk2dSprite mspr  = sprite.GetComponent<tk2dSprite>( );
     Color c = mspr.color;
     c.a = mYunMuCurrentAlpha;
     mspr.color = c;
 }
Exemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     anim = GetComponent<tk2dSpriteAnimator>();
     anim.Play("walking");
     distToGround = collider.bounds.extents.y;
     gravityTotal = gravity;
     sprite = GetComponent<tk2dSprite>();
 }
Exemplo n.º 10
0
        private void _getSprite() {
            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
            if(go == null) {
                return;
            }

            _sprite = go.GetComponent<tk2dSpriteAnimator>();
        }
		void AnimationEventDelegate (tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip, int frameNum)
		{
			tk2dSpriteAnimationFrame frame = clip.GetFrame(frameNum);
			Fsm.EventData.IntData = frame.eventInt;
			Fsm.EventData.StringData = frame.eventInfo;
			Fsm.EventData.FloatData = frame.eventFloat;
			Fsm.Event(animationTriggerEvent);
		}
Exemplo n.º 12
0
    protected override void OnAnimationClipEnd(tk2dSpriteAnimator aAnim, tk2dSpriteAnimationClip aClip) {
        if(anim == aAnim && aClip == mClips[(int)AnimState.attack]) {
            mActActive = false;
            mFireActive = false;
        }

        base.OnAnimationClipEnd(aAnim, aClip);
    }
Exemplo n.º 13
0
    void Awake()
    {
        // Setting up references.
        groundCheck = transform.Find("groundCheck");

        anim = GetComponent<tk2dSpriteAnimator> ();

        jumpSound = GetComponent<AudioSource> ();
    }
Exemplo n.º 14
0
	void OnSpawned () {

		_spriteAnim = GetComponent<tk2dSpriteAnimator>();

		if (anim)
			_spriteAnim.PlayFromFrame(0);

		StartCoroutine (TimedDespawn());
	}
 // This is called once the hit animation has compelted playing
 // It returns to playing whatever animation was active before hit
 // was playing.
 void HitCompleteDelegate(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip)
 {
     if (walking) {
         anim.Play("walk");
     }
     else {
         anim.Play("idle");
     }
 }
Exemplo n.º 16
0
 void Awake()
 {
     mAnispr = GetComponent<tk2dSpriteAnimator>();
     if (mAnispr == null)
         return;
     mOriClip = mAnispr.DefaultClip;
     //mOriClipidx = mAnispr.DefaultClipId;
     tk2dSpriteAnimationClip aniClip = mAnispr.Library.clips[mAnispr.Library.GetClipIdByName(AniName)];
     mSpecAniLength = aniClip.frames.Length / aniClip.fps;
 }
Exemplo n.º 17
0
        //-------------------------------------------------------------------------
        public void init(CRenderScene scene)
        {
            mScene = scene;
            mSprite = gameObject.GetComponent<tk2dSprite>();
            mSpriteAnimator = gameObject.GetComponent<tk2dSpriteAnimator>();
            mTransform = transform;

            if (mSpriteAnimator == null) return;
            setKinematic();
        }
Exemplo n.º 18
0
    void Awake()
    {
        groundCheck = transform.Find("GroundCheck");
        speedText = transform.Find("SpeedText").GetComponent<GUIText>();
        pGrind = GetComponent<PlayerGrind>();
        //anim = GetComponentInChildren<Animator>();

        //Animation
        playerAnimator = GetComponentInChildren<tk2dSpriteAnimator>();
    }
Exemplo n.º 19
0
	void CheckAddAnimatorInternal() {
		if (_animator == null) {
			_animator = gameObject.GetComponent<tk2dSpriteAnimator>();
			if (_animator == null) {
				_animator = gameObject.AddComponent<tk2dSpriteAnimator>();
				_animator.Library = anim;
				_animator.DefaultClipId = clipId;
				_animator.playAutomatically = playAutomatically;
			}
		}
	}
Exemplo n.º 20
0
	// Use this for initialization
	void Start () 
	{
		animator = GetComponent<tk2dSpriteAnimator>();
		animator.AnimationEventTriggered += AnimationEventHandler;
		
#if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9
		popupTextMesh.gameObject.active = false;
#else
		popupTextMesh.gameObject.SetActive(false);
#endif
	}
Exemplo n.º 21
0
 void HitCompleteDelegate(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip)
 {
     _state = EnemyStateEnum.Walking;
     if (_state == EnemyStateEnum.Walking)
     {
         anim.Play("EnemyWalk");
     }
     else if (_state == EnemyStateEnum.ThrowWeapon)
     {
         anim.Play("ThrowWeapon");
     }
 }
Exemplo n.º 22
0
	// Use this for initialization
	void Start () 
	{
		anim = GetComponent<tk2dSpriteAnimator>();
        _state = EnemyStateEnum.Walking;
		//isWalk = false;
		m_transform = transform;
		//isThrow = false;
        //GameObject.Find("MyRock");
		Invoke("ThrowWeapon",throwRate);
	
	
	}
Exemplo n.º 23
0
    void ThrowCompleteDelegate(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip)
	{
        _state = EnemyStateEnum.Walking;
		if (_state == EnemyStateEnum.Walking)
		{
			anim.Play("EnemyWalk");
		}
		else if(_state == EnemyStateEnum.Hited)
		{
			anim.Play("EnemyHited");
		}
	}
Exemplo n.º 24
0
	// Use this for initialization
	void Start ()
	{
		spriteAnimator = GetComponent<tk2dSpriteAnimator> ();
		mTk2dSprite = GetComponent<tk2dSprite> ();
		mover = GetComponent<Mover> ();
		setEvolutionPoint ();
		backGroundKeeper.UpdateBackGround (evolutionPoint);
		SetVoiceAudioClip ();
		SetAnimationObject ();
		animationObject.SetActive (false);
		StartIdleAnimation ();
	}
Exemplo n.º 25
0
 /// <summary>
 /// 绑定Animator
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public bool BindComp(Transform obj)
 {
     if (obj)
     {
         m_tAnimator = obj.GetComponent <tk2dSpriteAnimator>();
         if (m_tAnimator == null)
         {
             m_tAnimator = obj.gameObject.AddComponent <tk2dSpriteAnimator>();
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 26
0
    // Use this for initialization
    void Start()
    {
        if (initialInfoCard != null)
        {
            Camera.main.GetComponent <CameraControl>().pauseAndDrawInfoCard(initialInfoCard);
        }

        if (startInCutscene)
        {
            enterCutscene();
        }
        else
        {
            // Loads Prefabs directly from Resources Folder
            phoneBullet        = ((GameObject)Resources.Load("Phone Attacks/Bullet")).transform;
            phoneLazerBeam     = ((GameObject)Resources.Load("Phone Attacks/LazerBeam")).transform;
            phoneStunBullet    = ((GameObject)Resources.Load("Phone Attacks/StunBullet")).transform;
            phoneStunExplosion = ((GameObject)Resources.Load("Phone Attacks/StunExplosion")).transform;
            phoneStunLight     = ((GameObject)Resources.Load("Phone Attacks/StunLight")).transform;

            playerSprite = transform.FindChild("PlayerSprite");
            flashLight   = GetComponent <FlashlightControl>();

            // Player Audio sources - location in array dependent upon order of player components
            // first audio source listed is source[0]
            aSources               = GetComponents <AudioSource>();
            footStepsAudio         = aSources[0];
            swordAudioChannel      = aSources[1];
            takingDamageAudio      = aSources[2];
            itemPickupAudio        = aSources[3];
            noBatteryAudio         = aSources[4];
            batteryChargingAudio   = aSources[5];
            swordAudioChannel.loop = false;
            takingDamageAudio.loop = false;
            itemPickupAudio.loop   = false;


            curDirection   = FacingDirection.Down;
            curAnim        = transform.FindChild("PlayerSprite").GetComponent <tk2dSpriteAnimator>();
            curHealth      = maxHealth;
            curPhoneCharge = maxPhoneCharge;
            curStamina     = 0;

            rightSideHitbox = GameObject.Find("RightSideAttackHitbox").GetComponent <PlayerAttackHitbox>();
            leftSideHitbox  = GameObject.Find("LeftSideAttackHitbox").GetComponent <PlayerAttackHitbox>();
            upHitbox        = GameObject.Find("UpAttackHitbox").GetComponent <PlayerAttackHitbox>();
            downHitbox      = GameObject.Find("DownAttackHitbox").GetComponent <PlayerAttackHitbox>();

            invulnerable = false;
        }
    }
Exemplo n.º 27
0
        private IEnumerator ExplosionProcessor()
        {
            bool isCompleted = false;

            GetContext().Play(AnimationDefs.Explosion.ToString().ToLower());

            MonsterData        monster           = GetContext().data as MonsterData;
            tk2dSpriteAnimator explosionAnimator = ResourceUtils.GetComponent <tk2dSpriteAnimator>(GlobalDefinitions.RESOURCE_PATH_EFFECT_EXPLOSION + monster.explosionID);

            explosionAnimator.transform.SetParent(GetContext().transform);
            explosionAnimator.transform.position = GetContext().GetMountPoint(ComponentDefs.Body).position;

            explosionAnimator.AnimationCompleted = (tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip) =>
            {
                animator.AnimationCompleted = null;
                GameObject.Destroy(animator.gameObject);

                DeadProcessor();

                isCompleted = true;
            };

            float time = default(float);

            while (!isCompleted)
            {
                if (time > 0.5)
                {
                    AbstractComponentEffect effect = AbstractComponentEffect.LoadRandomEffect();
                    effect.transform.position = GetContext().GetMountPointAtRandom(Space.World);
                    effect.Initaizlie();

                    LayerManager.GetInstance().AddObject(effect.transform);

                    time = default(float);
                }

                time += Time.deltaTime;

                yield return(null);
            }

            for (int index = 0, amount = Random.Range(3, 5); index < amount; index++)
            {
                AbstractComponentEffect effect = AbstractComponentEffect.LoadRandomEffect();
                effect.transform.position = GetContext().GetMountPointAtRandom(Space.World);
                effect.Initaizlie();

                LayerManager.GetInstance().AddObject(effect.transform);
            }
        }
Exemplo n.º 28
0
        void Awake()
        {
            tk2dAnimator = gameObject.GetComponent <tk2dSpriteAnimator>();
            bodyCollider = gameObject.GetComponent <PolygonCollider2D>();
            body         = gameObject.GetComponent <Rigidbody2D>();
            meshRenderer = gameObject.GetComponent <MeshRenderer>();
            preventOOB   = gameObject.GetOrAddComponent <PreventOutOfBounds>();

            preventOOB.onBoundCollision -= OnCollision;
            preventOOB.onBoundCollision += OnCollision;

            meshRenderer.enabled = false;
            bodyCollider.offset  = new Vector2(0f, -.3f);
        }
 // Use this for initialization
 void Start()
 {
     animations     = GetComponent <tk2dSpriteAnimator>();
     movement       = GetComponent <RobotMovement>();
     smokeParticles = transform.GetChild(0).GetComponent <ParticleSystem>();
     if (!smokeParticles)
     {
         Debug.LogError("Robot does not have smoke particles as a child");
     }
     else
     {
         smokeParticles.enableEmission = false;
     }
 }
Exemplo n.º 30
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="eState">进入新状态后上一个状态</param>
    public virtual void EnterState(EActionState eState)
    {
        if (m_tk2DSpriteAnimator == null)
        {
            m_tk2DSpriteAnimator = m_owner.GetAbility <AnimationAbility>().GetTk2dSpriteAnimator();
        }

        if (m_stateManager == null)
        {
            m_stateManager = m_owner.GetStateMgr();
        }

        m_tk2DSpriteAnimator.AnimationCompleted = OnAnimationComplete;
    }
Exemplo n.º 31
0
    public void setRestAI()
    {
        GameObject obj = constant.getChildGameObject(this.gameObject, "AnimatedSprite");

        tk2dSpriteAnimator ani = obj.GetComponent <tk2dSpriteAnimator>();

        ani.Play("rest");

        mUseTime = mRestTime;

        enemy_property pro = this.gameObject.GetComponent <enemy_property>();

        pro.BaseMoveSpeed = 0;
    }
Exemplo n.º 32
0
        private void Awake()
        {
            Log("Added Hornet Mono");

            if (!DoH.Instance.IsInHall)
            {
                return;
            }
            _hm          = gameObject.GetComponent <HealthManager>();
            _stunControl = gameObject.LocateMyFSM("Stun Control");
            _control     = gameObject.LocateMyFSM("Control");
            _recoil      = gameObject.GetComponent <Recoil>();
            _anim        = gameObject.GetComponent <tk2dSpriteAnimator>();
        }
Exemplo n.º 33
0
        protected void UpdateBlinkShadow(PlayerController Owner, Vector2 delta, bool canWarpDirectly)
        {
            int?m_overrideFlatColorID = ReflectionHelpers.ReflectGetField <int>(typeof(PlayerController), "m_overrideFlatColorID", Owner);

            if (m_extantBlinkShadow == null)
            {
                GameObject go = new GameObject("blinkshadow");
                m_extantBlinkShadow = tk2dSprite.AddComponent(go, Owner.sprite.Collection, Owner.sprite.spriteId);
                m_extantBlinkShadow.transform.position = m_cachedBlinkPosition + (Owner.sprite.transform.position.XY() - Owner.specRigidbody.UnitCenter);
                tk2dSpriteAnimator tk2dSpriteAnimator = m_extantBlinkShadow.gameObject.AddComponent <tk2dSpriteAnimator>();
                tk2dSpriteAnimator.Library = Owner.spriteAnimator.Library;
                if (m_overrideFlatColorID.HasValue)
                {
                    m_extantBlinkShadow.renderer.material.SetColor(m_overrideFlatColorID.Value, (!canWarpDirectly) ? new Color(0.4f, 0f, 0f, 1f) : new Color(0.25f, 0.25f, 0.25f, 1f));
                }
                m_extantBlinkShadow.usesOverrideMaterial = true;
                m_extantBlinkShadow.FlipX = Owner.sprite.FlipX;
                m_extantBlinkShadow.FlipY = Owner.sprite.FlipY;
                Owner.OnBlinkShadowCreated?.Invoke(m_extantBlinkShadow);
            }
            else
            {
                if (delta == Vector2.zero)
                {
                    m_extantBlinkShadow.spriteAnimator.Stop();
                    m_extantBlinkShadow.SetSprite(Owner.sprite.Collection, Owner.sprite.spriteId);
                }
                else
                {
                    float?m_currentGunAngle = null;
                    try { m_currentGunAngle = ReflectionHelpers.ReflectGetField <float>(typeof(PlayerController), "m_currentGunAngle", Owner); } catch (Exception) { }
                    string baseAnimationName = string.Empty;
                    if (m_currentGunAngle.HasValue)
                    {
                        baseAnimationName = GetBaseAnimationName(Owner, delta, m_currentGunAngle.Value, false, true);
                    }
                    if (!string.IsNullOrEmpty(baseAnimationName) && !m_extantBlinkShadow.spriteAnimator.IsPlaying(baseAnimationName))
                    {
                        m_extantBlinkShadow.spriteAnimator.Play(baseAnimationName);
                    }
                }
                if (m_overrideFlatColorID.HasValue)
                {
                    m_extantBlinkShadow.renderer.material.SetColor(m_overrideFlatColorID.Value, (!canWarpDirectly) ? new Color(0.4f, 0f, 0f, 1f) : new Color(0.25f, 0.25f, 0.25f, 1f));
                }
                m_extantBlinkShadow.transform.position = m_cachedBlinkPosition + (Owner.sprite.transform.position.XY() - Owner.specRigidbody.UnitCenter);
            }
            m_extantBlinkShadow.FlipX = Owner.sprite.FlipX;
            m_extantBlinkShadow.FlipY = Owner.sprite.FlipY;
        }
Exemplo n.º 34
0
    void Start()
    {
        Transform          anchor = this.transform.FindChild(ClientStringConstants.BUILDING_ANCHOR_OBJECT_NAME);
        tk2dSpriteAnimator sp     = anchor.FindChild(BUILDING_BACKGROUND_OBJECT_NAME).
                                    GetComponent <tk2dSpriteAnimator>();

        //Debug.Log(anchor == null);
        //Debug.Log(sp == null);

        BoxCollider c = this.gameObject.AddComponent <BoxCollider>();

        c.center = anchor.localPosition + sp.Sprite.GetBounds().center;
        c.size   = sp.Sprite.GetBounds().extents;
    }
    void Awake()
    {
        if (anim == null)
        {
            anim = GetComponent <tk2dSpriteAnimator>();
        }

        if (spr == null)
        {
            spr = GetComponent <tk2dBaseSprite>();
        }

        mDoUpdate = new WaitForFixedUpdate();
    }
Exemplo n.º 36
0
    //private float salAttackX= 3.45f;

    // Use this for initialization
    void Start()
    {
        //Animation
        salAnimator = GetComponent <tk2dSpriteAnimator>();

        //Gamestates
        GameEventManager.GameStart += GameStart;
        GameEventManager.GameOver  += GameOver;
        startPosition = transform.localPosition;

        //Freeze the game until you start moving
        isActive = false;
        //gameObject.SetActive(false);
    }
Exemplo n.º 37
0
        //Initalizes the sprite game objects
        IEnumerator SpriteRoutine()
        {
            do
            {
                yield return(null);
            }while (HeroController.instance == null || GameManager.instance == null);


            try
            {
                prevFaceRightVal = HeroController.instance.cState.facingRight;

                gunSpriteGO = new GameObject("HollowPointGunSprite", typeof(SpriteRenderer), typeof(HP_GunSpriteRenderer), typeof(AudioSource));
                gunSpriteGO.transform.position      = HeroController.instance.transform.position;
                gunSpriteGO.transform.localPosition = new Vector3(0, 0, 0);
                gunSpriteGO.SetActive(true);

                transformSlave = new GameObject("slaveTransform", typeof(Transform));
                ts             = transformSlave.GetComponent <Transform>();
                //ts.transform.SetParent(HeroController.instance.transform);
                gunSpriteGO.transform.SetParent(ts);

                defaultWeaponPos = new Vector3(-0.2f, -0.84f, -0.0001f);
                shakeNum         = new System.Random();

                whiteFlashGO  = CreateGameObjectSprite("lightflash.png", "lightFlashGO", 30);
                muzzleFlashGO = CreateGameObjectSprite("muzzleflash.png", "bulletFadePrefabObject", 150);
            }
            catch (Exception e)
            {
                Log(e);
            }


            whiteFlashGO.SetActive(false);

            DontDestroyOnLoad(whiteFlashGO);
            DontDestroyOnLoad(transformSlave);
            DontDestroyOnLoad(gunSpriteGO);
            DontDestroyOnLoad(muzzleFlashGO);

            try
            {
                tk2d = HeroController.instance.GetComponent <tk2dSpriteAnimator>();
            }
            catch (Exception e)
            {
                Log(e);
            }
        }
Exemplo n.º 38
0
    void Start()
    {
        curAnim = GetComponent <tk2dSpriteAnimator>();
        _state  = GetComponent <ZombieSM>();
        CC      = GetComponent <CharacterController>();

        Sprite = GetComponent <tk2dSprite>();

        timeMod  = time;
        trueTime = 1f / timeMod;
        //Color orange = new Color(255, 80, 0, 255);
        Colors = new Color[] { Color.cyan, Color.green, Color.magenta, Color.yellow, Color.blue, Color.white, Color.grey, Color.red, Color.black };
        StartCoroutine(ChangeColor(trueTime));
    }
 private void CheckAddAnimatorInternal()
 {
     if (this._animator == null)
     {
         this._animator = base.gameObject.GetComponent<tk2dSpriteAnimator>();
         if (this._animator == null)
         {
             this._animator = base.gameObject.AddComponent<tk2dSpriteAnimator>();
             this._animator.Library = this.anim;
             this._animator.DefaultClipId = this.clipId;
             this._animator.playAutomatically = this.playAutomatically;
         }
     }
 }
Exemplo n.º 40
0
 void CheckAddAnimatorInternal()
 {
     if (_animator == null)
     {
         _animator = gameObject.GetComponent <tk2dSpriteAnimator>();
         if (_animator == null)
         {
             _animator                   = gameObject.AddComponent <tk2dSpriteAnimator>();
             _animator.Library           = anim;
             _animator.DefaultClipId     = clipId;
             _animator.playAutomatically = playAutomatically;
         }
     }
 }
    void Start()
    {
        animator = GetComponent <tk2dSpriteAnimator>();

        action    = "Walk";
        direction = "W";

        soundFX = GameObject.Find("SoundFX").GetComponent <SoundFX>();       // //connects to SoundFx - a sound source near the camera

        if (soldierType == "EventTrigger")
        {
            animator.AnimationEventTriggered += FireWeapon;
        }
    }
Exemplo n.º 42
0
        private void Slash()
        {
            IEnumerator DoSlash()
            {
                FlyMoveTo fm = gameObject.AddComponent <FlyMoveTo>();

                fm.enabled       = false;
                fm.target        = _target;
                fm.distance      = 3;
                fm.speedMax      = 12;
                fm.acceleration  = 0.75f;
                fm.targetsHeight = true;
                fm.height        = 0;
                fm.enabled       = true;
                yield return(new WaitWhile(() =>
                                           Vector2.Distance(_target.transform.position, transform.position) > 5f));

                Log("ATTACKING TIME");
                _anim.Play("Slash Antic");
                yield return(new WaitWhile(() => _anim.IsPlaying("Slash Antic")));

                Destroy(fm);
                //float dir = FaceHero();
                _rb.velocity = new Vector2(8f * side, 0f);
                _anim.Play("Slash Antic");
                _slash.SetActive(true);
                tk2dSpriteAnimator tk = _slash.GetComponent <tk2dSpriteAnimator>();

                _slash.GetComponent <PolygonCollider2D>().enabled = true;
                tk.Play("Slash Effect");
                yield return(null);

                _anim.Play("Slash");
                yield return(new WaitForSeconds(0.083f));

                yield return(new WaitWhile(() => _anim.IsPlaying("Slash")));

                _slash.GetComponent <PolygonCollider2D>().enabled = false;
                _slash.SetActive(false);
                _anim.Play("Slash CD");
                yield return(new WaitWhile(() => _anim.IsPlaying("Slash CD")));

                _anim.Play("Fly");
                StartCoroutine(AttackChooser());
            }

            //FaceHero();
            StartCoroutine(DoSlash());
        }
Exemplo n.º 43
0
        public static void Init()
        {
            string     itemName     = "Lead Soul";
            string     resourceName = "NevernamedsItems/Resources/leadsoul_icon";
            GameObject obj          = new GameObject(itemName);
            var        item         = obj.AddComponent <LeadSoul>();

            ItemBuilder.AddSpriteToObject(itemName, resourceName, obj);
            string shortDesc = "No Voice To Cry Suffering";
            string longDesc  = "Grants a regenerating shield." + "\n\nSteel yourself against the tribulations ahead, for the world is dark and cold...";

            ItemBuilder.SetupItem(item, shortDesc, longDesc, "nn");
            item.quality = PickupObject.ItemQuality.S;
            LeadSoulID   = item.PickupObjectId;
            item.SetupUnlockOnCustomFlag(CustomDungeonFlags.LICH_BEATEN_SHADE, true);

            #region VFXSetup
            GameObject plagueVFXObject = SpriteBuilder.SpriteFromResource("NevernamedsItems/Resources/MiscVFX/LeadSoulVFX/leadsouloverhead_001", new GameObject("LeadSoulOverhead"));
            plagueVFXObject.SetActive(false);
            tk2dBaseSprite plaguevfxSprite = plagueVFXObject.GetOrAddComponent <tk2dBaseSprite>();
            plaguevfxSprite.GetCurrentSpriteDef().ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter, plaguevfxSprite.GetCurrentSpriteDef().position3);
            FakePrefab.MarkAsFakePrefab(plagueVFXObject);
            UnityEngine.Object.DontDestroyOnLoad(plagueVFXObject);
            //Animating the overhead
            tk2dSpriteAnimator plagueanimator = plagueVFXObject.AddComponent <tk2dSpriteAnimator>();
            plagueanimator.Library       = plagueVFXObject.AddComponent <tk2dSpriteAnimation>();
            plagueanimator.Library.clips = new tk2dSpriteAnimationClip[0];

            tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip {
                name = "LeadSoulOverheadClip", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
            };
            foreach (string path in OverheadVFXPaths)
            {
                int spriteId = SpriteBuilder.AddSpriteToCollection(path, plagueVFXObject.GetComponent <tk2dBaseSprite>().Collection);

                plagueVFXObject.GetComponent <tk2dBaseSprite>().Collection.spriteDefinitions[spriteId].ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter);

                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame {
                    spriteId = spriteId, spriteCollection = plagueVFXObject.GetComponent <tk2dBaseSprite>().Collection
                };
                clip.frames = clip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }

            plagueanimator.Library.clips     = plagueanimator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray();
            plagueanimator.playAutomatically = true;
            plagueanimator.DefaultClipId     = plagueanimator.GetClipIdByName("LeadSoulOverheadClip");
            VFXPrefab = plagueVFXObject;
            #endregion
        }
Exemplo n.º 44
0
 //> AnimationCompleted
 protected virtual void OnAnimationClipEnd(tk2dSpriteAnimator aAnim, tk2dSpriteAnimationClip aClip)
 {
     if (aAnim == anim && aClip == mClips[(int)AnimState.attack])
     {
         //beginning first charge
         if (mFireActive && mClips[(int)AnimState.charge] != null)
         {
             //anim.Play(mClips[(int)AnimState.charge]);
         }
         else
         {
             anim.Play(mClips[(int)AnimState.normal]);
         }
     }
 }
        private void OnAnimationEventTriggered(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip, int frameIndex)
        {
            animator.AnimationEventTriggered -= OnAnimationEventTriggered;

            tk2dSpriteAnimationFrame frame = clip.GetFrame(frameIndex);

            if (frame.eventInfo == AnimationTriggerDefs.SkillApply.ToString())
            {
                skillUIElement.Apply(owner, data, targetPosition);

                skillUIElement = null;

                Destroy(this);
            }
        }
Exemplo n.º 46
0
 void OnAnimEvent(tk2dSpriteAnimator aAnim, tk2dSpriteAnimationClip aClip, int frame)
 {
     if (anim == aAnim && aClip == mClips[(int)AnimState.attack])
     {
         tk2dSpriteAnimationFrame frameDat = aClip.GetFrame(frame);
         if (frameDat.eventInfo == "actS")
         {
             mActActive = true;
         }
         else if (frameDat.eventInfo == "actE")
         {
             mActActive = false;
         }
     }
 }
Exemplo n.º 47
0
 private void UpdateAnimation(tk2dSpriteAnimator anim, bool playerRadius)
 {
     if (anim.IsPlaying("moving_box_in") || anim.IsPlaying("moving_box_out"))
     {
         return;
     }
     if (playerRadius && !anim.IsPlaying("moving_box_open"))
     {
         anim.Play("moving_box_open");
     }
     if (!playerRadius && !anim.IsPlaying("moving_box_close"))
     {
         anim.Play("moving_box_close");
     }
 }
Exemplo n.º 48
0
 void Start()
 {
     animator = GetComponent <tk2dSpriteAnimator>();
     AudioSource[] audio = GetComponents <AudioSource>();
     if (audio != null && audio.Length > 0)
     {
         destructionSound    = audio[0];         //GetComponent<AudioSource>();
         disintigrationSound = audio.Length > 1 ? audio[1] : null;
     }
     if (destructionSound != null)
     {
         destructionSound.loop = false;
     }
     calculateCutoffs();
 }
Exemplo n.º 49
0
 void InitAnimator()
 {
     if (_animator == null)
     {
         GameObject go = new GameObject("@SpriteAnimator");
         go.hideFlags = HideFlags.HideAndDontSave;
                         #if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9
         go.active = false;
                         #else
         go.SetActive(false);
                         #endif
         go.AddComponent <tk2dSprite>();
         _animator = go.AddComponent <tk2dSpriteAnimator>();
     }
 }
Exemplo n.º 50
0
 public override void OnAnimationComplete(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip animationClip)
 {
     base.OnAnimationComplete(animator, animationClip);
     if (m_fOffset > 0)
     {
         if (m_fV0 < 0)
         {
             m_stateManager.EnterState(EActionState.Jump_Fall, new object[] { m_fV0, m_fOffset });
         }
         else
         {
             m_stateManager.EnterState(EActionState.Jump_Up, new object[] { m_fV0, m_fOffset });
         }
     }
 }
Exemplo n.º 51
0
        // Token: 0x06004CAA RID: 19626 RVA: 0x00199814 File Offset: 0x00197A14
        public override void OnEffectRemoved(GameActor actor, RuntimeGameActorEffectData effectData)
        {
            if (actor.IsFrozen)
            {
                actor.FreezeAmount = 0f;
                float resistanceForEffectType = actor.GetResistanceForEffectType(this.resistanceType);
                float damage = Mathf.Max(0f, actor.healthHaver.GetMaxHealth() * this.UnfreezeDamagePercent * (1f - resistanceForEffectType));
                actor.healthHaver.ApplyDamage(damage, Vector2.zero, "Freezer Burn", CoreDamageTypes.Ice, DamageCategory.DamageOverTime, true, null, false);
                this.DestroyCrystals(effectData, !actor.healthHaver.IsDead);
                if (this.AppliesTint)
                {
                    actor.DeregisterOverrideColor(this.effectIdentifier);
                }
                if (actor.behaviorSpeculator)
                {
                    actor.behaviorSpeculator.enabled = true;
                }
                if (this.ShouldVanishOnDeath(actor))
                {
                    actor.StealthDeath = false;
                }
                actor.IsFrozen = false;
            }
            actor.MovementModifiers      -= effectData.MovementModifier;
            actor.healthHaver.OnPreDeath -= effectData.OnActorPreDeath;
            if (actor.aiAnimator)
            {
                actor.aiAnimator.FpsScale = 1f;
            }
            if (actor.aiShooter)
            {
                actor.aiShooter.AimTimeScale = 1f;
            }
            if (actor.behaviorSpeculator)
            {
                actor.behaviorSpeculator.CooldownScale = 1f;
            }
            if (actor.bulletBank)
            {
                actor.bulletBank.TimeScale = 1f;
            }
            tk2dSpriteAnimator spriteAnimator = actor.spriteAnimator;

            if (spriteAnimator && actor.aiAnimator && spriteAnimator.CurrentClip != null && !spriteAnimator.IsPlaying(spriteAnimator.CurrentClip))
            {
                actor.aiAnimator.PlayUntilFinished(actor.spriteAnimator.CurrentClip.name, false, null, -1f, true);
            }
        }
    void Awake()
    {
        MainCamera = GameObject.FindWithTag("MainCamera");

        if (this.tag == "Creature") //All objects are of type GameObject. Use tags instead of the usual typeOf() check.
            {
            if (GetComponent<Movement>() != null)
                {movement = GetComponent<Movement>();}			//Determine if attached script is Movement or PlayerMovement
            if (GetComponent<PlayerMovement>() != null)
                {movement = GetComponent<PlayerMovement>();}
            }

        animLib = GetComponent<tk2dSpriteAnimator>();
        setAction("stand");
        absoluteFacing = relativeFacing = initialFacing; //Later on, facing will also be randomized if a player drops the item.
                                                        //The constructor will take an int argument for the direction to give it.
                                                        //That way you can place objects in the editor with set directions, but it will
                                                        //also randomize if the player moves it around.

        MAP = new Dictionary<string, tk2dSpriteAnimationClip>();

            MAP["stand0"] = animLib.GetClipByName("standU");
            MAP["stand45"] = animLib.GetClipByName("standUR");		//Map clips to strings, so I can assemble
            MAP["stand90"] = animLib.GetClipByName("standR");		//them piece by piece rather than use a ton of ifs.
            MAP["stand135"] = animLib.GetClipByName("standDR");
            MAP["stand180"] = animLib.GetClipByName("standD");
            MAP["stand225"] = animLib.GetClipByName("standDL");
            MAP["stand270"] = animLib.GetClipByName("standL");
            MAP["stand315"] = animLib.GetClipByName("standUL");

            MAP["walk0"] = animLib.GetClipByName("walkU");
            MAP["walk45"] = animLib.GetClipByName("walkUR");
            MAP["walk90"] = animLib.GetClipByName("walkR");
            MAP["walk135"] = animLib.GetClipByName("walkDR");
            MAP["walk180"] = animLib.GetClipByName("walkD");
            MAP["walk225"] = animLib.GetClipByName("walkDL");
            MAP["walk270"] = animLib.GetClipByName("walkL");
            MAP["walk315"] = animLib.GetClipByName("walkUL");

            MAP["swing0"] = animLib.GetClipByName("swingU");
            MAP["swing45"] = animLib.GetClipByName("swingUR");
            MAP["swing90"] = animLib.GetClipByName("swingR");
            MAP["swing135"] = animLib.GetClipByName("swingDR");
            MAP["swing180"] = animLib.GetClipByName("swingD");
            MAP["swing225"] = animLib.GetClipByName("swingDL");
            MAP["swing270"] = animLib.GetClipByName("swingL");
            MAP["swing315"] = animLib.GetClipByName("swingUL");
    }
Exemplo n.º 53
0
    /// <summary>
    /// 更新所有序列帧
    /// </summary>
    public void playAllAnimation()
    {
        string clipName = GetClipName();

        Dictionary <string, tk2dSpriteAnimator> .Enumerator etor = animators.GetEnumerator();
        while (etor.MoveNext())
        {
            tk2dSpriteAnimator animator = etor.Current.Value;
            if (!animator.gameObject.activeSelf)
            {
                continue;
            }

            tk2dSpriteAnimationClip clip = animator.GetClipByName(clipName);

            if (null == clip)
            {
                clipName = GetClipName(PlayerAniConifg.directionStatus.SOUTHEAST, action, isRiding);
                clip     = animator.GetClipByName(clipName);
            }

            if (null == clip)
            {
                JZLog.LogWarning(etor.Current.Key + " 没有该动画数据: " + clipName);
                continue;
            }

            switch (action)
            {
            case PlayerAniConifg.actionStatus.DIE:
            case PlayerAniConifg.actionStatus.ATTACK:
            case PlayerAniConifg.actionStatus.HURT:
                clip.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once;
                break;

            default:
                clip.wrapMode = tk2dSpriteAnimationClip.WrapMode.Loop;
                break;
            }

            clip.fps = 30f;
            animator.DefaultClipId = 0;
            animator.PlayFromFrame(clip, 0);

            CheckRotation(etor.Current.Key, direction, animator);
            CheckLayer(etor.Current.Key, animator.gameObject.transform);
        }
    }
Exemplo n.º 54
0
    public void setSprintAI()
    {
        GameObject player = constant.getPlayer();

        if (player == null)
        {
            return;
        }

        enemy_property pro = this.gameObject.GetComponent <enemy_property>();

        pro.BaseMoveSpeed = this.mSprintMaxSpeed;
        if (this.mHasAngry)
        {
            pro.BaseMoveSpeed = this.mAngrySprintMaxSpeed;
        }

        GameObject obj = constant.getChildGameObject(this.gameObject, "AnimatedSprite");

        tk2dSpriteAnimator ani = obj.GetComponent <tk2dSpriteAnimator>();

        //spr.SetSprite("boss1_01");
        ani.Play("sprint");

        float x = player.transform.position.x - this.transform.position.x;
        float y = player.transform.position.y - this.transform.position.y;

        SphereCollider collider = this.GetComponent <SphereCollider>();

        Debug.Log("collider.bounds.size:" + collider.bounds.size.x + "," + collider.bounds.size.y);
        Debug.Log("dis:" + x + "," + y);
        if (collider.bounds.size.x / 2 > Mathf.Abs(x))
        {
            x = 0;
        }
        if (collider.bounds.size.y / 2 > Mathf.Abs(y))
        {
            y = 0;
        }

        float d = Mathf.Atan2(y, x);

        //Debug.Log("X,Y,D:" + x + "," + y + "," + d);
        mAddX = mSprintAcc * Mathf.Cos(d);
        mAddY = mSprintAcc * Mathf.Sin(d);

        //Debug.Log("mAddX,mAddY:" + mAddX + "," + mAddY);
    }
    void Start()
    {
        FZSM = GetComponent<FootballZombieSM>();
        curAnim = GetComponent<tk2dSpriteAnimator>();

        RaiseZombieZone = GameObject.Find("RaiseZombieZone").transform;
        ZoneMaxX = (int)RaiseZombieZone.collider.bounds.max.x;
        ZoneMinX = (int)RaiseZombieZone.collider.bounds.min.x;
        ZoneMaxY = (int)RaiseZombieZone.collider.bounds.max.y;
        ZoneMinY = (int)RaiseZombieZone.collider.bounds.min.y;

        print ("MAX: " + RaiseZombieZone.collider.bounds.max);
        print ("MIN: " + RaiseZombieZone.collider.bounds.min);

        // StartCoroutine(RaiseZombie());
    }
        /**
         * <summary>Checks if a 2Dtk Sprite is playing a specific animation.</summary>
         * <param name = "sprite">The Transform with the 2Dtk Sprite</param>
         * <param name = "clipName">The name of the animatino clip to check for</param>
         * <returns>True if the 2Dtk Sprite is playing the animation</returns>
         */
        public static bool IsAnimationPlaying(Transform sprite, string clipName)
        {
                        #if tk2DIsPresent
            tk2dSpriteAnimator      anim = sprite.GetComponent <tk2dSpriteAnimator>();
            tk2dSpriteAnimationClip clip = anim.GetClipByName(clipName);

            if (clip != null)
            {
                if (anim.IsPlaying(clip))
                {
                    return(true);
                }
            }
                        #endif
            return(false);
        }
    // Use this for initialization
    void Start () {
		
		hudInstance = GameObject.Find ("UnityHUDPrefab");
		if(hudInstance)
		{
			hudScript = hudInstance.GetComponent<HUD>();
		}
		
        // This script must be attached to the sprite to work.
        anim = GetComponent<tk2dSpriteAnimator>();
		
		InitAnimation();
		
		clientSocketScript = GameObject.Find("PlayerConnection").GetComponent<ClientSocket>();
		zooMapScript = GameObject.Find ("ZooMap").GetComponent<ZooMap>();
    }
    void Start()
    {
        FZSM    = GetComponent <FootballZombieSM>();
        curAnim = GetComponent <tk2dSpriteAnimator>();

        RaiseZombieZone = GameObject.Find("RaiseZombieZone").transform;
        ZoneMaxX        = (int)RaiseZombieZone.collider.bounds.max.x;
        ZoneMinX        = (int)RaiseZombieZone.collider.bounds.min.x;
        ZoneMaxY        = (int)RaiseZombieZone.collider.bounds.max.y;
        ZoneMinY        = (int)RaiseZombieZone.collider.bounds.min.y;

        print("MAX: " + RaiseZombieZone.collider.bounds.max);
        print("MIN: " + RaiseZombieZone.collider.bounds.min);

        // StartCoroutine(RaiseZombie());
    }
		void AnimationCompleteDelegate (tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip)
		{ 
			int clipId = -1;
			tk2dSpriteAnimationClip[] clips = (sprite.Library != null) ? sprite.Library.clips : null;
			if (clips != null) {
				for (int i = 0; i < clips.Length; ++i) {
					if (clips[i] == clip) {
						clipId = i;
						break;
					}
				}
			}

			Fsm.EventData.IntData = clipId;
			Fsm.Event (animationCompleteEvent);      
		}
Exemplo n.º 60
0
 private void AnimationCompleted(tk2dSpriteAnimator anim, tk2dSpriteAnimationClip clip)
 {
     if (stackMoves.Count == 0)
     {
         if (clip.name != "ShamanStay")
         {
             _isPlaying = false;
             Anim.Play("ShamanStay");
         }
     }
     else
     {
         _isPlaying = true;
         Anim.Play(stackMoves[0]);
         stackMoves.RemoveAt(0);
     }
 }