Example #1
0
    public override void LoadModel()
    {
        string modelPath = "Resources/" + J_ModelResource.GetData(towerInfo.towerData._modelId)._modelPath;

        towerAsset = GameLoader.Instance.LoadAssetSync(modelPath);
        towerObj   = towerAsset.GameObjectAsset;
        towerObj.transform.position = this.towerInfo.GetPosition();
        //增加点击事件
        AddClickInfo(towerObj, towerInfo.Id);
        //加载塔身图片
        GameObject towerBaseObj = towerObj.transform.Find("ArrowTowerBase").gameObject;

        towerBase = InitSpriteImage(towerBaseObj, towerInfo.towerBase);
        //加载射手1
        GameObject shooterObj1 = towerObj.transform.Find("ArrowShooter1").gameObject;

        shooter1 = InitAnimate(shooterObj1, towerInfo.shooter);
        //加载射手2
        GameObject shooterObj2 = towerObj.transform.Find("ArrowShooter2").gameObject;

        shooter2 = InitAnimate(shooterObj2, towerInfo.shooter);

        bulletPos1 = towerObj.transform.Find("BulletPos1").position;
        bulletPos2 = towerObj.transform.Find("BulletPos2").position;
        //根据塔基座大小增加碰撞盒
        //AddBoxColider(towerObj, towerBase.width, towerBase.height);
    }
Example #2
0
    public override void LoadModel()
    {
        string modelPath = "Resources/" + J_ModelResource.GetData(towerInfo.towerData._modelId)._modelPath;

        towerAsset = GameLoader.Instance.LoadAssetSync(modelPath);
        towerObj   = towerAsset.GameObjectAsset;
        towerObj.transform.position = this.towerInfo.GetPosition();
        bulletPos = towerObj.transform.Find("BulletPos1").position;
        //增加点击事件
        AddClickInfo(towerObj, towerInfo.Id);
        //加载塔身图片
        towerBase = InitAnimate(towerObj, towerInfo.towerBase);

        //根据塔基座大小增加碰撞盒
        //AddBoxColider(towerObj, 80, 70);
    }
Example #3
0
    void Start()
    {
        J_Map.LoadConfig();
        J_Creature.LoadConfig();
        J_SkillEvent.LoadConfig();
        J_Skill.LoadConfig();
        J_Tower.LoadConfig();
        J_AnimData.LoadConfig();
        J_Effect.LoadConfig();
        J_ModelResource.LoadConfig();

        EntityManager.getInstance();
        EntityViewManager.getInstance();

        //DataPreLoader.getInstance().LoadData("Monsters");
        //根据图片信息txt将图片里帧信息分离出来
        //SpriteFrameCache.getInstance().addSpriteFrameFromFile("Resources/Config/monster1.txt");
        SpriteFrameCache.getInstance().addSpriteFrameFromFile("Resources/Config/Helper.txt");
        SpriteFrameCache.getInstance().addSpriteFrameFromFile("Resources/Config/Monster1.txt");
        SpriteFrameCache.getInstance().addSpriteFrameFromFile("Resources/Config/Monster2.txt");
        SpriteFrameCache.getInstance().addSpriteFrameFromFile("Resources/Config/Solider1.txt");
        SpriteFrameCache.getInstance().addSpriteFrameFromFile("Resources/Config/Tower1.txt");
        SpriteFrameCache.getInstance().addSpriteFrameFromFile("Resources/Config/TowerShooter.txt");
        AnimationCache animCache = AnimationCache.getInstance();

        List <D_AnimData> animList = J_AnimData.ToList();
        int count = animList.Count;

        for (int i = 0; i < count; i++)
        {
            D_AnimData animData = animList[i];
            bool       loop     = (animData._loop == 1?true:false);
            //无动作动画
            if (animData._animName == "")
            {
                animCache.addAnimation(
                    animCache.createAnimation(animData._FrameName, animData._startFrame, animData._endFrame, animData._delta, loop, animData._xoffset, animData._yoffset),
                    animData._modelName
                    );
            }
            else
            {
                animCache.addAnimation(
                    animCache.createAnimation(animData._FrameName, animData._startFrame, animData._endFrame, animData._delta, loop, animData._xoffset, animData._yoffset),
                    animData._modelName,
                    animData._animName
                    );
            }
        }

        GameObject uiroot = GameObject.Find("Canvas").gameObject;

        UiManager.Instance.Init(uiroot);

        PathLoader pathloader = new PathLoader();

        pathloader.LoadPath("level1");
        PathInfo path = pathloader.GetPath("1");

        //path.PrintAllPoint();


        //charInfo.ChangeState("move");
        BattleFingerEvent.getInstance().ChangeState("start");
        //tower = EntityManager.getInstance().AddTower(100);
        //tower.SetPosition(0, 0, 0);
        //tower.ChangeState("idle");
        //CharacterInfo charInfo = EntityManager.getInstance().AddSolider(50001);
        //charInfo.SetPosition(0, 0, 0);
        //monster = EntityManager.getInstance().AddMonster(10001, path);
        //monster.SetPosition(0, 0, 0);
        //tower = EntityManager.getInstance().AddTower(11);
        //tower.SetPosition(0, 0, 0);
        //tower.ChangeState("idle");
        //tower = EntityManager.getInstance().AddTower(12);
        //tower.SetPosition(0, 0, 0);
        //tower.ChangeState("idle");
        //tower = EntityManager.getInstance().AddTower(13);
        //tower.SetPosition(0, 0, 0);
        //tower.ChangeState("idle");
        tower = EntityManager.getInstance().AddTower(15);
        tower.SetPosition(0, 0, 0);
        tower.ChangeState("idle");
        //tower = EntityManager.getInstance().AddTower(15);
        //tower.SetPosition(0, 0, 0);
        //tower.ChangeState("idle");

        baseEffect = EntityManager.getInstance().AddStaticEffect(17, Vector3.zero);


        //GameManager.getInstance().LoadLevel(1);
        //GameManager.getInstance().StartGame();

        monster = EntityManager.getInstance().AddMonster(10001, path);
        monster.SetPosition(100, 5, 0);
        //monster = EntityManager.getInstance().AddMonster(10001, path);
        //monster.SetPosition(250, 0, 0);
        //monster.SetPosition(116, -100, 0);
        //monster.ChangeState("move");

        //CharacterInfo charInfo = EntityManager.getInstance().AddSolider(50001);
        //charInfo.SetPosition(-180, -150, 0);
        //charInfo.DoAction("idle");
        //charInfo = EntityManager.getInstance().AddSolider(50001);
        //charInfo.SetPosition(-170, -150, 0);
        //charInfo.DoAction("idle");
    }