Ejemplo n.º 1
0
 // Enable 되면 실행되므로 화염 시작부분을 넣을 것
 public void Start()
 {
     Debug.Log("기본 화염 스크립트 시작 감지");
     Level1.SetActive(false);
     Level2.SetActive(false);
     Level3.SetActive(false);
     Level4.SetActive(false);
     nowLevel   = 0;
     nowRoutine = FireEffect();
     StartCoroutine(nowRoutine);
     o2Gauge  = FindObjectOfType <O2Gauge>();
     hpSystem = FindObjectOfType <HPSystem>();
 }
Ejemplo n.º 2
0
    public void SetHPSystem(HPSystem hpSystem)
    {
        this.hpSystem  = hpSystem;
        hpSystemStatic = hpSystem;

        List <HPSystem.HP> hpList             = hpSystem.GetHPList();
        Vector2            hpAnchoredPosition = new Vector2(0, 0);

        for (int i = 0; i < hpList.Count; i++)
        {
            HPSystem.HP hp = hpList[i];
            CreateHPImage(hpAnchoredPosition).SetHPFragments(hp.GetFragmentAmount());
            hpAnchoredPosition += new Vector2(20, 0);
        }

        hpSystem.OnDamaged += HPSystem_OnDamaged;
    }
Ejemplo n.º 3
0
 public BodyPartContainer(string name, float size, HPSystem hpSystem) : base(name, size, hpSystem)
 {
     this.BodyParts = new List <BodyPart>();
 }
Ejemplo n.º 4
0
 public BodyPart(string name, float size, HPSystem hpSystem) : this(name, size)
 {
     this.hpSystem = hpSystem;
 }
Ejemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     healthSystem = GameObject.FindGameObjectWithTag("Player").GetComponent <HPSystem>();
 }
Ejemplo n.º 6
0
 private void Awake()
 {
     instance = this;
 }
Ejemplo n.º 7
0
    private void Start()
    {
        HPSystem hpSystem = new HPSystem(5);

        SetHPSystem(hpSystem);
    }
Ejemplo n.º 8
0
        public static void ReadBodyPartsFromXml()
        {
            IsInitialized = true;

            AvailableBodyParts = new Dictionary <string, Dictionary <string, BodyPart> >();

            // STEP 1:
            // read names only
            List <string> bodyVariantsNames = BodyPartXmlReader.getChildren(new List <string>()
            {
                RootField, BaseStatsField
            });
            List <List <string> > bodyPartNamesPerVariant = new List <List <string> >();
            int countVariants = 0;

            foreach (var variantName in bodyVariantsNames)
            {
                List <string> bodyPartNames = BodyPartXmlReader.getChildren(new List <string>()
                {
                    RootField, BaseStatsField, variantName
                });

                bodyPartNamesPerVariant.Add(new List <string>());
                foreach (var bodyPartName in bodyPartNames)
                {
                    //Console.WriteLine("Adding bodyPartName " + bodyPartName);
                    bodyPartNamesPerVariant[countVariants].Add(bodyPartName);
                }

                countVariants++;
            }

            // STEP 2:
            // setup BodyPart Dictionary
            for (int i = 0; i < bodyVariantsNames.Count; i++)
            {
                var variantName = bodyVariantsNames[i];

                // check if variant exists
                if (!AvailableBodyParts.ContainsKey(variantName))
                {
                    AvailableBodyParts[variantName] = new Dictionary <string, BodyPart>();
                }

                //Console.WriteLine("variantName: " + variantName);

                foreach (var bodyPartName in bodyPartNamesPerVariant[i])
                {
                    bool isContainer = BodyPartXmlReader.getFloat(new List <string>()
                    {
                        RootField, BaseStatsField, variantName, bodyPartName, IsContainerField
                    }) == 1;
                    float hp = BodyPartXmlReader.getFloat(new List <string>()
                    {
                        RootField, BaseStatsField, variantName, bodyPartName, HpField
                    });
                    float size = BodyPartXmlReader.getFloat(new List <string>()
                    {
                        RootField, BaseStatsField, variantName, bodyPartName, SizeField
                    });

                    List <string> materialNames = BodyPartXmlReader.getStrings(
                        new List <string>()
                    {
                        RootField, BaseStatsField, variantName, bodyPartName, MaterialsField, ItemField, MaterialsNameField
                    });
                    List <string> materialWeights = BodyPartXmlReader.getStrings(
                        new List <string>()
                    {
                        RootField, BaseStatsField, variantName, bodyPartName, MaterialsField, ItemField, MaterialsSizeField
                    });

                    List <DamageMultiplier> multipliers = new List <DamageMultiplier>();
                    List <float>            weights     = new List <float>();
                    for (int j = 0; j < materialNames.Count; j++)
                    {
                        var   materialName   = materialNames[j];
                        float materialWeight = float.Parse(materialWeights[j]);
                        try
                        {
                            foreach (var mult in EntityMaterial.GetMaterial(materialName).DamageMultipliers)
                            {
                                multipliers.Add(mult);
                                weights.Add(materialWeight);
                            }
                        }
                        catch (Exception e) { /* do nothing */ }
                    }

                    multipliers = DamageMultiplier.Simplify(multipliers, weights);

                    HPSystem hpSystem = new HPSystem((int)hp, multipliers);

                    BodyPart bodyPart;
                    if (isContainer)
                    {
                        bodyPart = new BodyPartContainer(bodyPartName, size, hpSystem);
                    }
                    else
                    {
                        bodyPart = new BodyPart(bodyPartName, size, hpSystem);
                    }

                    // store bodypart
                    AvailableBodyParts[variantName][bodyPartName] = bodyPart;
                }
            }

            // STEP 3:
            // build bodies and add parts for containers
            List <string> variantNames = BodyPartXmlReader.getChildren(new List <string>()
            {
                RootField, InclusionField
            });

            foreach (var variantName in variantNames)
            {
                Body body = new Body(variantName);

                List <string> containerNames = BodyPartXmlReader.getChildren(new List <string>()
                {
                    RootField, InclusionField, variantName
                });

                foreach (var bodyPartName in containerNames)
                {
                    //Debug.Log("INCLUSION FOR " + variantName + " " + bodyPartName);

                    var bodyPart = AvailableBodyParts[variantName][bodyPartName];

                    BodyPartContainer container;
                    if (bodyPart.GetType() == typeof(BodyPartContainer))
                    {
                        container = (BodyPartContainer)bodyPart;
                    }
                    else
                    {
                        container = new BodyPartContainer(bodyPart);
                    }

                    List <string> partsList = BodyPartXmlReader.getChildren(
                        new List <string>()
                    {
                        RootField, InclusionField, variantName, bodyPartName
                    });

                    foreach (var partName in partsList)
                    {
                        //Debug.Log(variantName + " " + bodyPartName + " getting a new " + partName);

                        List <string> customNames = BodyPartXmlReader.getStrings(
                            new List <string>()
                        {
                            RootField, InclusionField, variantName, bodyPartName, partName, ItemField
                        });

                        if (customNames.Count == 0)
                        {
                            container.AddBodyPart(AvailableBodyParts[variantName][partName].Clone());
                        }

                        foreach (var customName in customNames)
                        {
                            BodyPart bp = AvailableBodyParts[variantName][partName].Clone();
                            bp.NameCustom = customName;
                            container.AddBodyPart(bp);
                        }
                    }

                    // write back
                    // TODO: check if this is necessary
                    AvailableBodyParts[variantName][bodyPartName] = container;

                    body.AddBodyPart(container);
                }

                AvailableBodies[variantName] = body;
            }
        }
Ejemplo n.º 9
0
 private void Start()
 {
     healthSystem = GameObject.FindGameObjectWithTag("Player").GetComponent <HPSystem>();
     gun          = GameObject.FindGameObjectWithTag("PlayerGun").GetComponent <Gameplay.Weapons.Weapon>();
 }