protected override void OnSpawn()
 {
     base.OnSpawn();
     kanim.Play("off", KAnim.PlayMode.Once, 1f, 0f);
 }
 public static void SetPortraitData(IAssignableIdentity identityObject, KBatchedAnimController controller, bool useDefaultExpression = true)
 {
     if (identityObject == null)
     {
         controller.gameObject.SetActive(false);
     }
     else
     {
         MinionIdentity minionIdentity = identityObject as MinionIdentity;
         if ((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null)
         {
             MinionAssignablesProxy minionAssignablesProxy = identityObject as MinionAssignablesProxy;
             if ((UnityEngine.Object)minionAssignablesProxy != (UnityEngine.Object)null && minionAssignablesProxy.target != null)
             {
                 minionIdentity = (minionAssignablesProxy.target as MinionIdentity);
             }
         }
         controller.gameObject.SetActive(true);
         controller.Play("ui_idle", KAnim.PlayMode.Once, 1f, 0f);
         SymbolOverrideController component = controller.GetComponent <SymbolOverrideController>();
         component.RemoveAllSymbolOverrides(0);
         if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
         {
             Accessorizer component2 = minionIdentity.GetComponent <Accessorizer>();
             foreach (AccessorySlot resource in Db.Get().AccessorySlots.resources)
             {
                 Accessory accessory = component2.GetAccessory(resource);
                 if (accessory != null)
                 {
                     component.AddSymbolOverride(resource.targetSymbolId, accessory.symbol, 0);
                     controller.SetSymbolVisiblity(resource.targetSymbolId, true);
                 }
             }
             component.AddSymbolOverride(Db.Get().AccessorySlots.HatHair.targetSymbolId, Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(component2.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol, 1);
             RefreshHat(minionIdentity, controller);
         }
         else
         {
             StoredMinionIdentity storedMinionIdentity = identityObject as StoredMinionIdentity;
             if ((UnityEngine.Object)storedMinionIdentity == (UnityEngine.Object)null)
             {
                 MinionAssignablesProxy minionAssignablesProxy2 = identityObject as MinionAssignablesProxy;
                 if ((UnityEngine.Object)minionAssignablesProxy2 != (UnityEngine.Object)null && minionAssignablesProxy2.target != null)
                 {
                     storedMinionIdentity = (minionAssignablesProxy2.target as StoredMinionIdentity);
                 }
             }
             if (!((UnityEngine.Object)storedMinionIdentity != (UnityEngine.Object)null))
             {
                 controller.gameObject.SetActive(false);
                 return;
             }
             foreach (AccessorySlot resource2 in Db.Get().AccessorySlots.resources)
             {
                 Accessory accessory2 = storedMinionIdentity.GetAccessory(resource2);
                 if (accessory2 != null)
                 {
                     component.AddSymbolOverride(resource2.targetSymbolId, accessory2.symbol, 0);
                     controller.SetSymbolVisiblity(resource2.targetSymbolId, true);
                 }
             }
             component.AddSymbolOverride(Db.Get().AccessorySlots.HatHair.targetSymbolId, Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(storedMinionIdentity.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol, 1);
             RefreshHat(storedMinionIdentity, controller);
         }
         float animScale = 1f;
         if ((UnityEngine.Object)GameScreenManager.Instance != (UnityEngine.Object)null && (UnityEngine.Object)GameScreenManager.Instance.ssOverlayCanvas != (UnityEngine.Object)null)
         {
             animScale = 0.2f * (1f / GameScreenManager.Instance.ssOverlayCanvas.GetComponent <KCanvasScaler>().GetUserScale());
         }
         controller.animScale = animScale;
         string s = "ui";
         controller.Play(s, KAnim.PlayMode.Loop, 1f, 0f);
         controller.SetSymbolVisiblity("snapTo_neck", false);
         controller.SetSymbolVisiblity("snapTo_goggles", false);
     }
 }
        public void Play(string anim)
        {
            KBatchedAnimController component = visualizer.GetComponent <KBatchedAnimController>();

            component.Play(anim, KAnim.PlayMode.Once, 1f, 0f);
        }
    private void Play(GameObject go, string anim)
    {
        KBatchedAnimController component = go.GetComponent <KBatchedAnimController>();

        component.Play(anim, KAnim.PlayMode.Once, 1f, 0f);
    }
Example #5
0
 private void ActiveateSaveIndicator(Game.CansaveCB cb)
 {
     readyForSaveCallback       = cb;
     controller.onAnimComplete += DoCallBack;
     controller.Play("working_pre", KAnim.PlayMode.Once, 1f, 0f);
 }
    public override void FixedUpdate(float dt)
    {
        Tuning tuning = TuningData <Tuning> .Get();

        float num = tuning.maxVelocity * tuning.maxVelocity;

        for (int i = 0; i < data.Count; i++)
        {
            GravityComponent value = data[i];
            if (!(value.elapsedTime < 0f) && !((UnityEngine.Object)value.transform == (UnityEngine.Object)null))
            {
                Vector3 position     = value.transform.GetPosition();
                Vector2 vector       = position;
                Vector2 vector2      = new Vector2(value.velocity.x, value.velocity.y + -9.8f * dt);
                float   sqrMagnitude = vector2.sqrMagnitude;
                if (sqrMagnitude > num)
                {
                    vector2 *= tuning.maxVelocity / Mathf.Sqrt(sqrMagnitude);
                }
                int  num2 = Grid.PosToCell(vector);
                bool flag = Grid.IsVisiblyInLiquid(vector + new Vector2(0f, value.radius));
                if (flag)
                {
                    flag = true;
                    float num3 = (float)(value.transform.GetInstanceID() % 1000) / 1000f * 0.25f;
                    float num4 = tuning.maxVelocityInLiquid + num3 * tuning.maxVelocityInLiquid;
                    if (sqrMagnitude > num4 * num4)
                    {
                        float num5 = Mathf.Sqrt(sqrMagnitude);
                        vector2 = vector2 / num5 * Mathf.Lerp(num5, num3, dt * (5f + 5f * num3));
                    }
                }
                value.velocity     = vector2;
                value.elapsedTime += dt;
                Vector2 vector3 = vector + vector2 * dt;
                Vector2 pos     = vector3;
                pos.y -= value.radius;
                bool flag2 = Grid.IsVisiblyInLiquid(vector3 + new Vector2(0f, value.radius));
                if (!flag && flag2)
                {
                    KBatchedAnimController kBatchedAnimController = FXHelpers.CreateEffect("splash_step_kanim", new Vector3(vector3.x, vector3.y, 0f) + new Vector3(-0.38f, 0.75f, -0.1f), null, false, Grid.SceneLayer.FXFront, false);
                    kBatchedAnimController.Play("fx1", KAnim.PlayMode.Once, 1f, 0f);
                    kBatchedAnimController.destroyOnAnimComplete = true;
                }
                int num6 = Grid.PosToCell(pos);
                if (Grid.IsValidCell(num6))
                {
                    if (vector2.sqrMagnitude > 0.2f && Grid.IsValidCell(num2) && !Grid.Element[num2].IsLiquid && Grid.Element[num6].IsLiquid)
                    {
                        AmbienceType ambience = Grid.Element[num6].substance.GetAmbience();
                        if (ambience != AmbienceType.None)
                        {
                            string text = Sounds.Instance.OreSplashSoundsMigrated[(int)ambience];
                            if ((UnityEngine.Object)CameraController.Instance != (UnityEngine.Object)null && CameraController.Instance.IsAudibleSound(vector3, text))
                            {
                                SoundEvent.PlayOneShot(text, vector3);
                            }
                        }
                    }
                    bool flag3 = Grid.Solid[num6];
                    if (!flag3 && value.landOnFakeFloors && Grid.FakeFloor[num6])
                    {
                        Navigator component = value.transform.GetComponent <Navigator>();
                        if ((bool)component)
                        {
                            flag3 = component.NavGrid.NavTable.IsValid(num6, NavType.Floor);
                            if (!flag3)
                            {
                                int cell = Grid.CellAbove(num6);
                                flag3 = component.NavGrid.NavTable.IsValid(cell, NavType.Hover);
                            }
                        }
                    }
                    if (flag3)
                    {
                        Vector3 vector4 = Grid.CellToPosCBC(Grid.CellAbove(num6), Grid.SceneLayer.Move);
                        vector3.y         = vector4.y + value.radius;
                        value.velocity.x  = 0f;
                        value.elapsedTime = -1f;
                        value.transform.SetPosition(new Vector3(vector3.x, vector3.y, position.z));
                        data[i] = value;
                        value.transform.gameObject.Trigger(1188683690, vector2);
                        if (value.onLanded != null)
                        {
                            value.onLanded();
                        }
                    }
                    else
                    {
                        Vector2 pos2 = vector3;
                        pos2.x -= value.radius;
                        int num7 = Grid.PosToCell(pos2);
                        if (Grid.IsValidCell(num7) && Grid.Solid[num7])
                        {
                            vector3.x        = Mathf.Floor(vector3.x - value.radius) + (1f + value.radius);
                            value.velocity.x = -0.1f * value.velocity.x;
                            data[i]          = value;
                        }
                        else
                        {
                            Vector3 pos3 = vector3;
                            pos3.x += value.radius;
                            int num8 = Grid.PosToCell(pos3);
                            if (Grid.IsValidCell(num8) && Grid.Solid[num8])
                            {
                                vector3.x        = Mathf.Floor(vector3.x + value.radius) - value.radius;
                                value.velocity.x = -0.1f * value.velocity.x;
                                data[i]          = value;
                            }
                        }
                        value.transform.SetPosition(new Vector3(vector3.x, vector3.y, position.z));
                        data[i] = value;
                    }
                }
                else
                {
                    value.transform.SetPosition(new Vector3(vector3.x, vector3.y, position.z));
                    data[i] = value;
                }
            }
        }
    }
Example #7
0
    private void SetAnim(string animName)
    {
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();

        component.Play(animName, KAnim.PlayMode.Once, 1f, 0f);
    }
Example #8
0
 public void Enter()
 {
     animController.Play(anim, mode, 1f, 0f);
 }
Example #9
0
        // This method syncs the object to the transform of the neck snap point in the dupe
        void LateUpdate()
        {
            bool symbolVisible = false;

            if (dupeAnim.CurrentAnim != null)
            {
                var batch = dupeAnim.GetBatch();
                var frame = batch.group.data.GetFrame(dupeAnim.GetCurrentFrameIndex());
                if (frame != KAnim.Anim.Frame.InvalidFrame)
                {
                    for (int i = 0; i < frame.numElements; i++)
                    {
                        int num = frame.firstElementIdx + i;
                        if (num < batch.group.data.frameElements.Count)
                        {
                            KAnim.Anim.FrameElement frameElement = batch.group.data.frameElements[num];
                            if (frameElement.symbol == symbol)
                            {
                                if (frameElement.frame == 0)
                                {
                                    if (facing <= 0)
                                    {
                                        myAnim.Play(front_anim);
                                        facing = 1;
                                    }
                                }
                                else
                                {
                                    if (facing >= 0)
                                    {
                                        myAnim.Play(back_anim);
                                        facing = -1;
                                    }
                                }
                            }
                        }
                    }
                }

                symbolVisible = dupeAnim.GetSymbolVisiblity(symbol);
                bool      unusedBool;
                Matrix2x3 symbolLocalTransform = dupeAnim.GetSymbolLocalTransform(symbol, out unusedBool);
                Vector3   position             = dupeAnim.transform.GetPosition();
                if (symbolVisible && (previousMatrix != symbolLocalTransform || position != previousPosition))
                {
                    previousMatrix   = symbolLocalTransform;
                    previousPosition = position;
                    Matrix2x3 overrideTransformMatrix = dupeAnim.GetTransformMatrix() * symbolLocalTransform;
                    float     z = base.transform.GetPosition().z;
                    base.transform.SetPosition(overrideTransformMatrix.MultiplyPoint(offset));

                    Vector3 v  = dupeAnim.FlipX ? Vector3.left : Vector3.right;
                    Vector3 v2 = dupeAnim.FlipY ? Vector3.down : Vector3.up;
                    base.transform.up    = overrideTransformMatrix.MultiplyVector(v2);
                    base.transform.right = overrideTransformMatrix.MultiplyVector(v);
                    if (myAnim != null)
                    {
                        myAnim.GetBatchInstanceData()?.SetOverrideTransformMatrix(overrideTransformMatrix);
                    }

                    base.transform.SetPosition(new Vector3(base.transform.GetPosition().x, base.transform.GetPosition().y, z));

                    myAnim.Offset = dupeAnim.Offset;
                    myAnim.SetDirty();
                }
            }
            if (myAnim != null && symbolVisible != myAnim.enabled)
            {
                myAnim.enabled = symbolVisible;
            }
        }