예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (currentFighter != cm.currentFighter)
        {
            currentFighter = cm.currentFighter;

            foreach (Transform child in currentMeshHolder.transform)
            {
                Destroy(child.gameObject);
            }


            if (currentFighter.eCreatureType == CreatureType.Human)
            {
                currentMeshHolder.transform.position = positionHuman.transform.position;

                //  GameObject gHuman = prefabManager.GetHuman(currentFighter.nID);

                GameObject gHuman = prefabManager.GetHumanOfSex(currentFighter.nID, currentFighter.sexe);
                int        layer  = LayerMask.NameToLayer("UI");


                ModelHumainUI modelUI      = gHuman.GetComponent <ModelHumainUI>();
                ModelHumainUI modelCurrent = ((Human)currentFighter).currentUI.gameObject.GetComponentInChildren <ModelHumainUI>();

                modelUI.SetCaract(modelCurrent.caractCheveux);

                GameObject instanceHuman = Instantiate(gHuman, Vector3.zero, Quaternion.Euler(0, 90, 0)) as GameObject;
                instanceHuman.transform.parent        = currentMeshHolder.transform;
                instanceHuman.transform.localPosition = Vector3.zero;

                instanceHuman.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            }
            else
            {
                currentMeshHolder.transform.position = positionMonster.transform.position;

                GameObject gMonster = prefabManager.GetMonster(currentFighter.nID);

                ModelMonsterUI modelUI      = gMonster.GetComponent <ModelMonsterUI>();
                ModelMonsterUI modelCurrent = ((Monster)currentFighter).currentUI.gameObject.GetComponentInChildren <ModelMonsterUI>();

                modelUI.SetCaract(modelCurrent.caractMonster);

                GameObject instanceMonster = Instantiate(gMonster, Vector3.zero, Quaternion.Euler(0, 90, 0)) as GameObject;
                instanceMonster.transform.parent        = currentMeshHolder.transform;
                instanceMonster.transform.localPosition = Vector3.zero;


                instanceMonster.transform.localScale = new Vector3(-0.5f, 0.5f, 0.5f);
            }
        }

        if (cm.bCombatEnded && !processedEnd)
        {
            processedEnd = true;

            if (cm.bSpecialFight && cm.specialType == SpecialType.Bard)
            {
                foreach (Transform child in currentMeshHolder.transform)
                {
                    Destroy(child.gameObject);
                }
                currentMeshHolder.transform.position = positionHuman.transform.position;

                GameObject gHuman = prefabManager.GetSpecial(31);
                //  ModelHumainUI modelUI = gHuman.GetComponent<ModelHumainUI>();
                //  ModelHumainUI modelCurrent = ((Human)currentFighter).currentUI.gameObject.GetComponentInChildren<ModelHumainUI>();

                //  modelUI.SetCaract(modelCurrent.caractCheveux);

                GameObject instanceHuman = Instantiate(gHuman, Vector3.zero, Quaternion.Euler(0, 90, 0)) as GameObject;
                instanceHuman.transform.parent        = currentMeshHolder.transform;
                instanceHuman.transform.localPosition = Vector3.zero;

                instanceHuman.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            }
        }

        if (talk.active == true)
        {
            currentMeshHolder.SetActive(true);
            foreach (Transform child in currentMeshHolder.transform)
            {
                child.gameObject.SetActive(true);
            }
        }

        else
        {
            foreach (Transform child in currentMeshHolder.transform)
            {
                child.gameObject.SetActive(false);
            }
        }
    }
예제 #2
0
    void InstantiateMonster()
    {
        monsterGroupFighter = new GroupMonsterFighter();

        GameObject   prefab = prefabMonster;
        Fighter      fighter;
        CreatureType creatureType = CreatureType.Monster;

        GameObject       monstersPositionParent = GameObject.FindGameObjectWithTag("MonstersPosition");
        List <Transform> monstersPosition       = new List <Transform>();

        foreach (Transform child in monstersPositionParent.transform)
        {
            monstersPosition.Add(child);
        }


        for (int i = 0; i < nbCreaturePerGroup && i < caravane.lFighters.Count; i++)
        {
            fighter = caravane.lFighters[i];
            fighter.bTryToescape = false;
            GameObject g = Instantiate(prefab, monstersPosition[i].position, Quaternion.Euler(0, 90, 0)) as GameObject;

            GameObject mo;

            GameObject model = creaturePrefabManager.GetMonster(fighter.nID);
            mo = Instantiate(model, monstersPosition[i].position, Quaternion.Euler(0, 270, 0)) as GameObject;


            mo.transform.parent        = g.transform;
            mo.transform.localPosition = Vector3.zero;
            mo.transform.localScale    = new Vector3(0.3f, 0.3f, 0.3f);

            mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>();


            g.GetComponent <FighterUI>().fighter = fighter;

            monsterGroupFighter.lFighters.Add(fighter);
            g.transform.parent = GameObject.FindGameObjectWithTag("Monsters").transform;
            g.name             = fighter.sName;

            MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>();
            mouseOver.fighterUI = g.GetComponent <FighterUI>();

            g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>();
        }

        if (isBossCombat)
        {
            monstersPosition = new List <Transform>();
            foreach (Transform child in monstersPositionParent.transform)
            {
                monstersPosition.Add(child);
            }

            humanGroupFighter = new GroupEd();

            int        idModel = 40;
            GameObject model   = creaturePrefabManager.GetSpecial(idModel);
            //Human humain = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent<CreaturesData>().GetFighterOfID<Human>(creatureType, idModel);
            Monster monster = new Monster();
            monster.nID            = idModel;
            monster.sName          = "PiratePlant";
            monster.isBoss         = true;
            monster.nPower         = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent <CreaturesData>().defaultMonster.nPower;
            monster.nHealthMax     = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent <CreaturesData>().defaultMonster.nHealthMax;
            monster.nCurrentHealth = monster.nHealthMax;

            GameObject g = Instantiate(prefab, monstersPosition[4].position, Quaternion.Euler(0, 90, 0)) as GameObject;

            GameObject mo = Instantiate(model, monstersPosition[4].position, Quaternion.Euler(0, 90, 0)) as GameObject;
            mo.transform.parent        = g.transform;
            mo.transform.localPosition = Vector3.zero;
            mo.transform.localScale    = new Vector3(-0.3f, 0.3f, 0.3f);

            mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>();

            MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>();
            mouseOver.fighterUI = g.GetComponent <FighterUI>();

            g.GetComponent <FighterUI>().fighter = monster;
            monsterGroupFighter.lFighters.Add(monster);
            g.transform.parent = GameObject.FindGameObjectWithTag("Monsters").transform;
            g.name             = monster.sName;

            g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>();
        }
    }