예제 #1
0
파일: Goblin.cs 프로젝트: sogatron/Kismet
        /// <summary>
        /// Constructors a new sprite.
        /// </summary>        
        public Goblin(ContentManager p_Content, string p_XMLFile, Vector2 p_InitialPosition)
        {
            Sprite = new Sprite(p_Content, p_XMLFile);
            Sprite.Scale = 1.0f;
            State = new AwakeState(this);
            Direction = GV.LEFT;
            Velocity = new Vector2(0, 0);
            PositionInTile(p_InitialPosition);
            IsAlive = true;
            Health = 100;
            IsOnGround = false;

            StateMachine = new StateMachine(this, new AwakeState(this));

            StateMachine.AddState("KismetDataTypes.AwakeState", "", "PatrolState");

            StateMachine.AddState("KismetDataTypes.PatrolState", "insight", "PursueState");
            StateMachine.AddState("KismetDataTypes.PatrolState", "jump", "EnemyJumpingState");
            StateMachine.AddState("KismetDataTypes.PatrolState", "isHit", "KnockedDownState");

            StateMachine.AddState("KismetDataTypes.EnemyJumpingState", "", "PatrolState");
            StateMachine.AddState("KismetDataTypes.EnemyJumpingState", "isHit", "KnockedDownState");

            StateMachine.AddState("KismetDataTypes.PursueState", "collision", "AttackState");
            StateMachine.AddState("KismetDataTypes.PursueState", "noCollision", "PatrolState");
            StateMachine.AddState("KismetDataTypes.PursueState", "isHit", "KnockedDownState");

            StateMachine.AddState("KismetDataTypes.KnockedDownState", "", "PatrolState");

            StateMachine.AddState("KismetDataTypes.AttackState", "", "PatrolState");
            StateMachine.AddState("KismetDataTypes.AttackState", "isHit", "KnockedDownState");
        }
예제 #2
0
 public void Switch(float fadeSpeed, float fadingSpeed, RawImage currentImage, RawImage newImage, Camera currentCam, Camera newCam, Light currentLight, Light newLight, float currentLightFade,
                    float newLightFade, UnityAction afterTransition, LayerMask newSolid, AwakeState newState, Material currentSbMaterial, Material newSbMaterial, Color currentAmbientColor, Color newAmbientColor)
 {
     if (b != newImage.color || c != currentImage.color)
     {
         newLight.gameObject.SetActive(true);
         newCam.gameObject.SetActive(true);
         b = newImage.color;
         d = b.a;
         c = currentImage.color;
         a = c.a;
     }
     if (transitionOut)
     {
         blendTime += fadeSpeed * Time.deltaTime;
         RenderSettings.skybox.Lerp(currentSbMaterial, newSbMaterial, blendTime);
         RenderSettings.ambientLight = Color.Lerp(currentAmbientColor, newAmbientColor, blendTime);
         a  -= fadeSpeed * Time.deltaTime;
         d  += fadeSpeed * Time.deltaTime;
         c.a = Mathf.Clamp01(a);
         b.a = Mathf.Clamp01(d);
         currentImage.color      = c;
         newImage.color          = b;
         currentLight.intensity -= currentLightFade * Time.deltaTime;
         newLight.intensity     += newLightFade * Time.deltaTime;
         foreach (Camera cam in cameras)
         {
             cam.fieldOfView += fadingSpeed * Time.deltaTime;
         }
     }
     if (a < 0 || a > 1)
     {
         DynamicGI.UpdateEnvironment();
         blendTime = 0f;
         currentLight.gameObject.SetActive(false);
         transitionOut = false;
         transitionIn  = true;
         map           = newSolid;
         afterTransition();
     }
     if (transitionIn)
     {
         //foreach (Camera cam in cameras) {
         //    cam.fieldOfView -= Time.deltaTime * transitionSpeed * 2;
         //}
         if ((state == AwakeState.Nightmare /* && newCam.fieldOfView < 60*/) || (state == AwakeState.Dream /* && newCam.fieldOfView < 45*/))
         {
             transitionIn = false;
             currentCam.gameObject.SetActive(false);
             state = newState;
             print(currentCam.gameObject.name);
         }
     }
 }
예제 #3
0
    void Start()
    {
        RenderSettings.skybox.Lerp(dreamSbMaterial, nightmareSbMaterial, 0);
        RenderSettings.ambientLight = dreamAmbientColor;
        map   = dreamSolid;
        state = AwakeState.Dream;
        cm    = FindObjectOfType <CharacterMover>();
        nmCam.gameObject.SetActive(false);
        dreamSnapshot.TransitionTo(0);
        Fabric.EventManager.Instance.PostEvent("DreamMusic", Fabric.EventAction.PlaySound);
        Fabric.EventManager.Instance.PostEvent("NightmareMusic", Fabric.EventAction.PlaySound);

        //Fabric.EventManager.Instance.PostEvent("NightmareMusic", Fabric.EventAction.PauseSound);
    }