Пример #1
0
 //target描述,此特效的主调者
 //timePlayed用于同步动作和特效。快速出招时,特效要加一个已经播放时间,否则特效跟不上动作的播放步骤
 public SFXEffectPlay PlayEffect(string file, CharacterLoader target, float timePlayed = 0.0f)
 {
     if (!EffectList.ContainsKey(file))
     {
         SfxFile f = new SfxFile();
         try
         {
             f.ParseFile(file);
             EffectList[file] = f;
             //Debug.LogError("effect file:" + file);
             return(f.Play(target, timePlayed));
         }
         catch (Exception exp)
         {
             Debug.LogError(string.Format("{0}  parse error {1}", file, exp.Message));
             EffectList[file] = f;
         }
     }
     else
     {
         //Debug.LogError("effect file:" + file);
         if (EffectList[file].error)
         {
             return(null);
         }
         return(EffectList[file].Play(target, timePlayed));
     }
     return(null);
 }
Пример #2
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 virtual protected void Init()
 {
     counterText = GetComponent <Text> ();
     if (characterHealth == null)
     {
         characterHealth = FindObjectOfType <CharacterHealth>();
         if (characterHealth == null)
         {
             characterLoader = CharacterLoader.GetCharacterLoader();
             if (characterLoader != null)
             {
                 characterLoader.CharacterLoaded += HandleCharacterLoaded;
             }
             else
             {
                 Debug.LogError("Couldn't find a character health or a character loader");
             }
         }
     }
     if (characterHealth != null)
     {
         characterHealth.Died      += HandleChange;
         characterHealth.Loaded    += HandleChange;
         characterHealth.GainLives += HandleChange;
     }
 }
Пример #3
0
    public void sunset_loaded_callback(AssetBundle aBundle, string aBundleName)
    {
        mLoader = new CharacterLoader();
        mLoader.complete_load_character(aBundle, aBundleName);

        mBackground = new FlatElementImage(mLoader.Images.background1, mLoader.Sizes.mBackSize, 0);
        mBackground.HardPosition = mFlatCamera.get_point(0, 0);
        mStubbyHairyGrass        = construct_flat_image("BG-1", 2);

        mElement.Add(mBackground);
        mElement.Add(mStubbyHairyGrass);

        var sun = mManager.mCharacterBundleManager.get_image("SUN");

        mSun = new FlatElementImage(sun.Image, sun.Data.Size, 1);
        var light = mManager.mCharacterBundleManager.get_image("SHINE");

        mLightRay = new FlatElementImage(light.Image, light.Data.Size, 1);
        mLightRay.HardPosition = mFlatCamera.get_point(0, -10000);
        mElement.Add(mSun);
        mElement.Add(mLightRay);

        //mManager.mCharacterBundleManager.add_bundle_to_unload(aBundle);
        IsLoaded = true;

        //prep the sky for fetus
        set_sun(-1, true);
        set_sky_color(0);
    }
Пример #4
0
    public FlatBodyObject(CharacterLoader aChar, int aDepth = -1)
    {
        //hacky head reorder code
        bool reorder = false;

        if (ManagerManager.Manager.mCharacterBundleManager.get_character_helper() != null)
        {
            if (ManagerManager.Manager.mCharacterBundleManager.get_character_stat(aChar.Character).CharacterInfo.Order != 0)
            {
                reorder = true;
            }
        }

        //TODO fake thread this eventually please..
        foreach (FlatBodyObject e in load_sequential(aChar.Images, aChar.Sizes, reorder))
        {
            ;
        }

        mOffset = (new Vector3(aChar.Sizes.mOffset.x, aChar.Sizes.mOffset.y, 0));

        PrimaryGameObject = new GameObject("genBodyParent");
        mParts[ZgJointId.Waist].transform.parent = PrimaryGameObject.transform;
        mParts[ZgJointId.Torso].transform.parent = PrimaryGameObject.transform;
        SoftColor         = new Color(0.5f, 0.5f, 0.5f, 0.5f);
        SoftInterpolation = 0.08f;

        //this breaks everything...
        UseDepth = (aDepth != -1);
        if (UseDepth)
        {
            Depth = aDepth;
        }
    }
Пример #5
0
    public void load_character(CharacterLoader aLoader)
    {
        NGM.mManager.mBackgroundManager.load_character(aLoader);

        FlatBodyObject flatbody = new FlatBodyObject(aLoader, -1);

        flatbody.set_target_pose(NGM.CurrentPose, true);
        flatbody.HardPosition = new Vector3(10, 0, 0);
        flatbody.update(0);
        flatbody.set_layer(1 << 1);

        flatbody.PrimaryGameObject.name = "SIMIANBODY";


        //needed to make debugviewerthing work
        var cam = mManager.gameObject.AddComponent <Camera>();

        cam.transform.position = mManager.mCameraManager.MainBodyCamera.transform.position;
        cam.transform.rotation = mManager.mCameraManager.MainBodyCamera.transform.rotation;
        cam.fieldOfView        = mManager.mCameraManager.MainBodyCamera.fieldOfView;
        cam.orthographic       = mManager.mCameraManager.MainBodyCamera.orthographic;
        cam.orthographicSize   = mManager.mCameraManager.MainBodyCamera.orthographicSize;
        Debug.Log(mManager.mCameraManager.MainBodyCamera.orthographicSize);
        cam.depth       = 9999999;
        cam.clearFlags  = CameraClearFlags.Depth;
        cam.cullingMask = 0;

        mSimian = new FarseerSimian();
        mSimian.initialize(mManager.gameObject);
        mSimian.setup_with_body(flatbody);

        //this is stupid
        mSimian.add_environment(GameObject.FindObjectsOfType(typeof(Transform)).Where(e => e.name.StartsWith("FS_")).Select(e => ((Transform)e).gameObject));
    }
Пример #6
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 virtual protected void Init()
 {
     counterText = GetComponent <Text> ();
     if (itemManager == null)
     {
         itemManager = FindObjectOfType <ItemManager>();
         if (itemManager == null)
         {
             characterLoader = FindObjectOfType <CharacterLoader>();
             if (characterLoader != null)
             {
                 characterLoader.CharacterLoaded += HandleCharacterLoaded;
             }
             else
             {
                 Debug.LogError("UIStackable_ItemCounter could not find an ItemManager or Character Loader.");
             }
         }
         else
         {
             itemManager.ItemCollected       += HandleItemCollected;
             itemManager.ItemConsumed        += HandleItemCollected;
             itemManager.Loaded              += HandleItemCollected;
             LevelManager.Instance.Respawned += HandleRespawned;
         }
     }
     else
     {
         itemManager.ItemCollected       += HandleItemCollected;
         itemManager.ItemConsumed        += HandleItemCollected;
         itemManager.Loaded              += HandleItemCollected;
         LevelManager.Instance.Respawned += HandleRespawned;
     }
 }
Пример #7
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 protected virtual void Init()
 {
     if (character == null)
     {
         character = GameObject.FindObjectOfType <Character>();
     }
     if (character == null)
     {
         characterLoader = CharacterLoader.GetCharacterLoader();
         if (characterLoader != null)
         {
             characterLoader.CharacterLoaded += HandleCharacterLoaded;
         }
         else
         {
             Debug.LogWarning("Game over screen cannot find a Character.");
         }
     }
     else if (autoShowOnGameOver)
     {
         characterHealth = character.GetComponentInChildren <CharacterHealth>();
         if (characterHealth)
         {
             characterHealth.GameOver += HandleGameOver;
         }
         else
         {
             Debug.LogWarning("Game over screen cannot be auto shown as it could not find a ChracterHealth");
         }
     }
 }
Пример #8
0
 //target描述,此特效的主调者
 //timePlayed用于同步动作和特效。快速出招时,特效要加一个已经播放时间,否则特效跟不上动作的播放步骤
 public SFXEffectPlay PlayEffect(string file, CharacterLoader target, float timePlayed = 0.0f)
 {
     if (!EffectList.ContainsKey(file))
     {
         SfxFile f = new SfxFile();
         try
         {
             if (f.ParseFile(file))
             {
                 EffectList.Add(file, f);
                 //Debug.LogError("effect file:" + file);
                 return(f.Play(target, timePlayed));
             }
         }
         catch
         {
             Debug.LogError(file + " parse error");
         }
     }
     else
     {
         //Debug.LogError("effect file:" + file);
         return(EffectList[file].Play(target, timePlayed));
     }
     return(null);
 }
Пример #9
0
    //TODO should call this directly and get rid of that stupid callback thing in events
    public void load_character(CharacterLoader aCharacter)
    {
        unload();

        if (aCharacter != null && aCharacter.Name != "999")
        {
            mFlat = new FlatBodyObject(aCharacter, -1);
            set_layer(mLayer);
            if (ManagerManager.Manager.mGameManager.CurrentLevel == 0)
            {
                mFlat.HardPosition = Random.insideUnitCircle.normalized * 30000;
            }
            else
            {
                mFlat.HardPosition = Random.insideUnitCircle.normalized * 1000;
            }
            mFlat.SoftPosition = Vector3.zero;
            mOffset            = (new Vector3(aCharacter.Sizes.mOffset.x, aCharacter.Sizes.mOffset.y, 0));
            mFlat.SoftPosition = mFlat.SoftPosition + mOffset;

            if (mMode == 0)
            {
                mFlat.SoftColor = new Color(0.5f, 0.5f, 0.5f, 0.5f);
            }
            else if (mMode == 1)
            {
                //mFlat.SoftColor = new Color(0.5f, 0.5f, 0.5f, 0.35f);
                mFlat.HardShader = mManager.mReferences.mTransparentCharacaterShader;
                mFlat.HardColor  = mManager.mCharacterBundleManager.get_character_stat(aCharacter.Character).CharacterInfo.CharacterOutlineColor;
            }

            mFlat.update(0);
        }
    }
Пример #10
0
 public void gift_loaded_callback(AssetBundle aBundle, string aBundleName)
 {
     mLoader = new CharacterLoader();
     mLoader.complete_load_character(aBundle, aBundleName);
     //mManager.mCharacterBundleManager.add_bundle_to_unload(aBundle);
     IsLoaded = true;
 }
Пример #11
0
    //note aCharacter need not be the same as teh original character (use this or death)
    public void load_cutscene(int aNum, CharacterLoader aCharacter)
    {
        hide_bg_and_fg_elements();
        string prefix = "CUTSCENE" + aNum + "_";

        load_images(aCharacter, mForegroundElements, sForegroundStartingDepth, prefix);
        set_foreground_layer(mForegroundLayer);
    }
Пример #12
0
 /// <summary>
 /// Initializes the needed classes for the mod.
 /// </summary>
 private void InitializeClasses()
 {
     PackHelper    = new ContentPackHelper(this);
     Dresser       = new DresserHandler(this, Config);
     PlayerLoader  = new CharacterLoader(this, PackHelper, Dresser);
     MenuPatcher   = new SaveLoadMenuPatcher(this, PlayerLoader);
     HarmonyHelper = new HarmonyHelper(this);
 }
Пример #13
0
    public void load_images(CharacterLoader aCharacter, List <FlatElementImage> aImages, int startingDepth, string aPrefix, int aBegin = 0)
    {
        //last to first stupid hack..
        List <CharacterData.ImageSizeOffsetAnimationData> dataList = new List <CharacterData.ImageSizeOffsetAnimationData>();
        List <string> nameList = new List <string>();

        for (int i = aBegin; i < 100; i++)
        {
            string name = aPrefix + i;
            CharacterData.ImageSizeOffsetAnimationData data = aCharacter.Sizes.find_static_element(name);
            if (data == null)            //sometimes there are zero prefixes
            {
                name = aPrefix + "0" + i;
                data = aCharacter.Sizes.find_static_element(name);
            }
            if (data == null)
            {
                break;
            }

            //Debug.Log("loading " + name);



            dataList.Add(data);
            nameList.Add(name);
        }

        for (int i = dataList.Count - 1; i >= 0; i--)
        {
            Texture2D tex = aCharacter.Images.staticElements[nameList[i]];
            //if(tex == null)
            //throw new UnityException("data exists for " + data.Name + " but texture does not");
            var img = new FlatElementImage(tex, dataList[i].Size, startingDepth + aImages.Count);


            //fly in
            //img.HardPosition = random_position();
            //img.SoftPosition = dataList[i].Offset;

            //fade in
            img.HardColor    = GameConstants.UiWhiteTransparent;
            img.SoftColor    = GameConstants.UiWhite;
            img.HardPosition = dataList[i].Offset;

            aImages.Add(img);

            var fx = AnimationEffects.get_effect(dataList[i].AnimationEffect);
            fx = null;             //TODO
            if (fx != null)
            {
                img.Events.add_event(
                    fx
                    , 0);
            }
            //dataList[i].AnimationEffect
        }
    }
Пример #14
0
    public CharacterRoster()
    {
        employedCharacters = new List <PlayercontrolledCharacter>();
        _characterLoader   = new CharacterLoader <PlayercontrolledCharacter>();

        employedCharacters.Add(_characterLoader.GetCharacterByType("Kobold"));
        employedCharacters.Add(_characterLoader.GetCharacterByType("Kobold"));
        employedCharacters.Add(_characterLoader.GetCharacterByType("Theif"));
        employedCharacters.Add(_characterLoader.GetCharacterByType("Ghost"));
    }
Пример #15
0
        //static public ScreenManager ScreenManager
        //{
        //    //get { return (screenManager == null ? null : GameMain.screenManager); }
        //    get { return screenManager; }
        //}

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Globals.Initialize();
            InputManager.Initialize();
            ScreenManager.ScreenManagerInit(graphics, mapGenContentManager, this);
            CharacterLoader.Initialize(contentMan);
            base.Initialize();

            ScreenManager.AddScreen(new MainMenuStartScreen(Color.Blue, Fonts.normFont, VPCenter));
        }
Пример #16
0
    public SFXEffectPlay Play(CharacterLoader character, float timePlayed = 0.0f)
    {
        if (effectList.Count == 0)
        {
            return(null);
        }
        SFXEffectPlay effectContainer = character.gameObject.AddComponent <SFXEffectPlay>();

        effectContainer.Load(this, timePlayed);
        return(effectContainer);
    }
    public void mini_loaded_callback(AssetBundle aBundle, string aBundleName)
    {
        CharacterIndex index = (new CharacterIndex(aBundleName));

        using (mMiniCharLock)
        {
            mMiniCharacters[index] = new CharacterLoader();
            mMiniCharacters[index].complete_load_character(aBundle, aBundleName);
        }
        aBundle.Unload(false);
        mNumberMiniCharactersLoading--;
    }
    private static void SetupGameData()
    {
        // TODO: setup based on level info
//		HUDLoader.LoadHud("hud_bundle");

        // TODO: setup based on players added
        CharacterLoader.LoadCharacter("Axel");
//		CharacterLoader.LoadCharacter("Axel_HD");
//		CharacterLoader.LoadCharacter("Bat_HD");
//		CharacterLoader.LoadCharacter("happy char");
//		CharacterLoader.LoadCharacter("Axel_px");
    }
Пример #19
0
    void Start()
    {
        controller        = GameObject.FindObjectOfType <PlayerController>();
        movement          = GameObject.FindObjectOfType <PlayerUnityMovement>();
        characterLoader   = this.GetComponent <CharacterLoader>();
        dialogueGUIFiller = GameObject.FindObjectOfType <NPCDialogueGUI>();
        dialogueCanvas    = dialogueGUIFiller.transform.GetChild(0).gameObject;

        cameras = GameObject.FindObjectOfType <PlayerCameras>();

        dialogueCanvas.SetActive(false);
    }
Пример #20
0
 public void Init(Entity owner)
 {
     Owner           = owner;
     characterLoader = owner.GetComponent <CharacterLoader>();
     EntityId        = Owner == null ? 0 : Owner.EntityId;
     if (!PosFile.ContainsKey(EntityId))
     {
         int TargetIdx = EntityId >= 20 ? 0 : EntityId;
         PosFile.Add(EntityId, Resources.Load <TextAsset>("9.07" + "/P" + TargetIdx + ".pos"));
         ActionList.Add(EntityId, new List <Pose>());
         ReadPose();
     }
 }
Пример #21
0
        /// <summary>
        /// Glam Menu's Constructor.
        /// </summary>
        /// <param name="entry">Instance of <see cref="ModEntry"/></param>
        /// <param name="packHelper">Instance of <see cref="ContentPackHelper"/></param>
        /// <param name="dresser">Instance of <see cref="DresserHandler"/></param>
        /// <param name="playerLoader">Instance of <seealso cref="CharacterLoader"/></param>
        public GlamMenu(ModEntry entry, ModConfig config, ContentPackHelper packHelper, DresserHandler dresser, CharacterLoader playerLoader, PlayerChanger changer)
            : base((int)Utility.getTopLeftPositionForCenteringOnScreen(712, 712, 0, 0).X, (int)Utility.getTopLeftPositionForCenteringOnScreen(712, 712, 0, 0).Y - IClickableMenu.borderWidth, 712, 712, false)
        {
            Entry          = entry;
            Config         = config;
            PackHelper     = packHelper;
            Dresser        = dresser;
            PlayerLoader   = playerLoader;
            PlayerChanger  = changer;
            MenuComponents = new GlamMenuComponents(Entry, this, packHelper);

            CheckPlayerForHat();
            MenuComponents.SetUpMenuComponents();
        }
Пример #22
0
    public CharIndexContainerCharacterLoader()
    {
        int ageCount = GameConstants.numberAges;

        Contents = new CharacterLoader[ageCount][];
        for (int i = 0; i < ageCount; i++)
        {
            int charCount = GameConstants.numberChoices[i];
            for (int j = 0; j < charCount; j++)
            {
                Contents[i] = new CharacterLoader[charCount];
            }
        }
    }
Пример #23
0
    public void start_screen_loaded_callback(AssetBundle aBundle, string aBundleName)
    {
        mBundle = aBundle;

        CharacterLoader loader = new CharacterLoader();

        loader.complete_load_character(aBundle, aBundleName);
        mLoader = loader;


        //create background
        mElement.Add(construct_flat_image("BACKGROUND", 0));
        mElement.Add(construct_flat_image("FG-1", 30));
        for (int i = 2; i < 30; i++)
        {
            var img = construct_flat_image("BG-" + i, 30 - i);
            mElement.Add(img);
        }
        set_start_screen_character_transparency();


        NewMenuReferenceBehaviour refs = mManager.mNewRef;

        //kinect required image
        if (!GameConstants.ALLOW_NO_KINECT && mManager.mZigManager.is_reader_connected() == 0)
        {
            //TODO put up a KINECT REQUIRED message
            mKinectRequiredImage = construct_flat_image("FG-1", 1000);
            mKinectRequiredImage.SoftPosition += new Vector3(0, -400, 0);
            mElement.Add(mKinectRequiredImage);
        }


        //mMenuBackground;
        //mMenuSelector;
        //mResume;
        //mRestart;



        //????
        mMessageText = new FlatElementText(refs.genericFont, 60, "", 1);
        mMessageText.HardPosition = mRTCamera.get_point(Vector3.zero) + new Vector3(0, 400, 0);
        mElement.Add(mMessageText);

        start_configuration_display();

        IsInitialized = true;
    }
Пример #24
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        CharacterLoader myTarget = (CharacterLoader)target;

        source = GUILayout.TextField(source);
        frame  = GUILayout.TextField(frame);
        if (GUILayout.Button("PlayFrame"))
        {
            if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(frame))
            {
                myTarget.ChangeFrame(int.Parse(source), int.Parse(frame));
            }
        }
    }
    public void scene_loaded_callback(AssetBundle aBundle, string aBundleName)
    {
        //Debug.Log("loading character in CharacterLoader " + aBundleName);
        //TODo don't do this serial
        CharacterLoader loader = new CharacterLoader();

        loader.complete_load_character(aBundle, aBundleName);

        if (mManager.mGameManager.character_changed_listener(loader))
        {
            aBundle.Unload(false);
        }
        else
        {
            mUnloadAtEnd.Add(aBundle);
        }
    }
Пример #26
0
        private void LoadContent(ref ContentManager contentMan)
        {
            normalmapEffect = ScreenManager.contentMan.Load <Effect>("normalmap");

            MapEngine.LoadContent(ScreenManager.contentMan);
            InfoWriter.LoadContent();

            MapEngine.NewMap();
            MapEngine.LoadMap();
            mapLoaded = true;

            curPlayer = new Player(ref ScreenManager.contentMan, "test_hero", MapEngine.currMap.startPoint, Directions.S,
                                   CharacterLoader.LoadCharacter(ref ScreenManager.contentMan, "test_hero", "Player"));
            curPlayer.MapSprite.texture         = ScreenManager.contentMan.Load <Texture2D>(curPlayer.MapSprite.textureName);
            curPlayer.MapSprite.FrameDimensions = new Point(55, 55);
            curPlayer.MapSprite.ResetAnimation();
        }
Пример #27
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 virtual protected void Init()
 {
     images = GetComponentsInChildren <Image> ();
     if (images == null || images.Length == 0)
     {
         Debug.LogWarning("No health images found by UIHealth_Icons. These should be children of the UIHealth_Icons GameObject.");
     }
     else if (sprites == null || sprites.Length == 0)
     {
         Debug.LogWarning("No health images found.");
     }
     else
     {
         if (characterHealth == null)
         {
             // No health assigned try to find one
             if (characterLoader == null)
             {
                 characterLoader = CharacterLoader.GetCharacterLoader();
             }
             if (characterLoader != null)
             {
                 characterLoader.CharacterLoaded += HandleCharacterLoaded;
             }
             else
             {
                 characterHealth = GameObject.FindObjectOfType <CharacterHealth> ();
                 if (characterHealth == null)
                 {
                     Debug.LogWarning("Couldn't find a character health!");
                 }
             }
         }
         if (characterHealth != null)
         {
             if (images.Length * sprites.Length != characterHealth.MaxHealth)
             {
                 Debug.LogWarning("Number of images times number of sprites should match the MaxHealth");
             }
         }
     }
     if (characterHealth != null)
     {
         RegisterListeners();
     }
 }
Пример #28
0
 /// <summary>
 /// Hitting the action key does nothing for this menu item type.
 /// </summary>
 override public void DoAction()
 {
     CharacterLoader.ShouldLoadCharacters(new List <string> ()
     {
         supportingString
     });
     if (sceneToLoadOnSelect != null && sceneToLoadOnSelect != "")
     {
                         #if !UNITY_4_6 && !UNITY_4_7 && !UNITY_5_1 && !UNITY_5_2
         LevelManager.PreviousLevel = SceneManager.GetActiveScene().name;
         SceneManager.LoadScene(sceneToLoadOnSelect);
                         #else
         LevelManager.PreviousLevel = Application.loadedLevelName;
         Application.LoadLevel(sceneToLoadOnSelect);
                         #endif
     }
 }
Пример #29
0
    private LevelContext CreateContext(LevelData leveldata)
    {
        CardLoader      _cardLoader      = new CardLoader();
        MonsterLoader   monsterLoader    = new MonsterLoader();
        CharacterLoader _characterLoader = new CharacterLoader();

        //init level context
        LevelContext context = new LevelContext();

        context.LevelData = leveldata;
        context.Player    = _characterLoader.LoadUserCharacter();
        context.EnemyList.AddRange(monsterLoader.LoadEnemies(leveldata.Level, leveldata.Mission));
        context.ElementCardList.AddRange(_cardLoader.LoadUserCards(context.Player.Properties.ElementCards));
        context.UltimateCardList.AddRange(_cardLoader.LoadUltimateCards(context.Player.Properties.UltimateCards));

        return(context);
    }
 protected virtual void Init()
 {
     barImage = GetComponent<Image> ();
     if (characterHealth == null)
     {
         // No health assigned try to find one
         if (characterLoader == null) characterLoader = CharacterLoader.GetCharacterLoader();
         if (characterLoader != null)
         {
             characterLoader.CharacterLoaded += HandleCharacterLoaded;
         }
         else
         {
             characterHealth = GameObject.FindObjectOfType<CharacterHealth> ();
             if (characterHealth == null) Debug.LogWarning ("Couldn't find a character health!");
         }
     }
 }
Пример #31
0
    private void UpdateShadow(GameEntityModel model, GameObject entityObject)
    {
        GameObject       shadowObj  = CharacterLoader.GetCharacterShadow(model, entityObject);
        PhysicPointModel pointModel = GameEntityController.GetPointModel(model);

        if (shadowObj == null || pointModel == null)
        {
            return;
        }

        Vector3 newShadowPosition;

        if (pointModel.collisionInpact.Y < 0)
        {
            newShadowPosition = pointModel.position.AsVector3();
        }
        else
        {
            // Raycast on physics
            WorldModel world = StateManager.state.MainModel as WorldModel;
            if (world == null)
            {
                return;
            }
            PhysicWorldModel physicsModel = StateManager.state.GetModel(world.physicsModelId) as PhysicWorldModel;
            if (physicsModel == null)
            {
                return;
            }
            PhysicWorldController physicsController = physicsModel.Controller() as PhysicWorldController;
            if (physicsController == null)
            {
                return;
            }

            PhysicPointModel entityPoint  = GameEntityController.GetPointModel(model);
            FixedVector3     intersection = physicsController.Raycast(physicsModel, entityPoint.position, FixedVector3.Down);

            newShadowPosition = intersection.AsVector3();
        }
        // TODO: coordinates conversion from a setup file
        shadowObj.transform.position      = PhysicPoint2DView.ConvertGameToViewCoordinates(newShadowPosition);
        shadowObj.transform.localPosition = new Vector3(0, shadowObj.transform.localPosition.y, 0.02f);
    }
 /// <summary>
 /// Init this instance.
 /// </summary>
 protected virtual void Init()
 {
     counterText = GetComponent<Text> ();
     if (itemManager == null)
     {
         itemManager = FindObjectOfType<ItemManager>();
         if (itemManager == null)
         {
             characterLoader = FindObjectOfType<CharacterLoader>();
             if (characterLoader != null) characterLoader.CharacterLoaded += HandleCharacterLoaded;
             else Debug.LogError("UIStackable_ItemCounter could not find an ItemManager or Character Loader.");
         }
         else
         {
             itemManager.ItemCollected += HandleItemCollected;
             itemManager.ItemConsumed += HandleItemCollected;
             itemManager.Loaded += HandleItemCollected;
             LevelManager.Instance.Respawned += HandleRespawned;
         }
     }
     else
     {
         itemManager.ItemCollected += HandleItemCollected;
         itemManager.ItemConsumed += HandleItemCollected;
         itemManager.Loaded += HandleItemCollected;
         LevelManager.Instance.Respawned += HandleRespawned;
     }
 }
Пример #33
0
    public void Update(uint id, AssemblerInfo info)
    {
        if (info == null) return;

        //Debug.Log(".Update  " + id + " " + JsonWriter.Serialize(info));

        info.m_ID = id;

        if (!string.IsNullOrEmpty(info.m_Character)
            && !s_CharacterLoaders.ContainsKey(info.m_Character))
        {
            CharacterLoader cl = new CharacterLoader(info.m_Character + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterLoaders.Add(info.m_Character, cl);
        }

        if (!string.IsNullOrEmpty(info.m_HeadElement)
            && !s_CharacterElementLoaders.ContainsKey(info.m_HeadElement))
        {
            CharacterElementLoader cel = new CharacterElementLoader(info.m_HeadElement, info.m_HeadElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_HeadElement, cel);
        }

        if (!string.IsNullOrEmpty(info.m_BodyElement)
            && !s_CharacterElementLoaders.ContainsKey(info.m_BodyElement))
        {
            CharacterElementLoader cel = new CharacterElementLoader(info.m_BodyElement, info.m_BodyElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_BodyElement, cel);
        }

        if (!string.IsNullOrEmpty(info.m_FootElement)
            && !s_CharacterElementLoaders.ContainsKey(info.m_FootElement))
        {
            CharacterElementLoader cel = new CharacterElementLoader(info.m_FootElement, info.m_FootElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_FootElement, cel);
        }

        if (!string.IsNullOrEmpty(info.m_Character)
            && !s_AnimationAssemblers.ContainsKey(info.m_Character + AssemblerConstant.ANIMATION_SUFFIX))
        {
            AnimationLoader aa = new AnimationLoader(info.m_Character + AssemblerConstant.ANIMATION_SUFFIX + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_AnimationAssemblers.Add(info.m_Character + AssemblerConstant.ANIMATION_SUFFIX, aa);
        }

        if (!string.IsNullOrEmpty(info.m_WeaponR)
            && !s_ModelLoaders.ContainsKey(info.m_WeaponR))
        {
            ModelLoader ml = new ModelLoader(info.m_WeaponR + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_ModelLoaders.Add(info.m_WeaponR, ml);
        }

        if (!string.IsNullOrEmpty(info.m_WeaponL)
            && !s_ModelLoaders.ContainsKey(info.m_WeaponL))
        {
            ModelLoader ml = new ModelLoader(info.m_WeaponL + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_ModelLoaders.Add(info.m_WeaponL, ml);
        }

        //if (!string.IsNullOrEmpty(info.m_Wing)
        //    && !s_CharacterLoaders.ContainsKey(info.m_Wing))
        //{

        //}

        if (!string.IsNullOrEmpty(info.m_WingElement)
            && !s_CharacterElementLoaders.ContainsKey(info.m_WingElement))
        {

            CharacterLoader ml = new CharacterLoader(info.m_WingElement + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterLoaders.Add(info.m_WingElement, ml);

            AnimationLoader aa = new AnimationLoader(info.m_WingElement + AssemblerConstant.ANIMATION_SUFFIX + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_AnimationAssemblers.Add(info.m_WingElement + AssemblerConstant.ANIMATION_SUFFIX, aa);

            CharacterElementLoader cel = new CharacterElementLoader(info.m_WingElement, info.m_WingElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_WingElement, cel);
        }

        //if (!string.IsNullOrEmpty(info.m_Wing)
        //    && !s_AnimationAssemblers.ContainsKey(info.m_Wing + AssemblerConstant.ANIMATION_SUFFIX))
        //{

        //}

        info.m_IsDone = false;
        if (m_Assemblers.ContainsKey(id))
        {
            m_Assemblers[id] = new AssemblerInfo(ref info);
            //m_Assemblers.Remove(id);
        }
        else
        {
            m_Assemblers.Add(id, info);
        }

        if (!mCorout_isRunning)
        {
            mCorout_isRunning = true;
            StartCoroutine(LoadCoroutine());
        }

        //Debug.Log("Create assemble: " + DecToHex(id) + " status: " + info.m_IsDone);

        return;
    }