示例#1
0
        public void StateEnter()
        {
            input.OnPrimaryKeyPressed   += PlayerInputOnPrimaryKeyPressed;
            input.OnSecondaryKeyPressed += PlayerInputOnSecondaryKeyPressed;

            if (buildData.ExtractedEssences == null || buildData.ExtractedEssences.Count < 2)
            {
                return;
            }

            var firstEssence  = buildData.ExtractedEssences[0].GetComponent <Essence>();
            var secondEssence = buildData.ExtractedEssences[1].GetComponent <Essence>();
            var result        = recipes.TryMerge(firstEssence, secondEssence);

            if (result == null)
            {
                return;
            }


            for (int i = 0; i < buildData.ExtractedEssences.Count; i++)
            {
                Object.Destroy(buildData.ExtractedEssences[i]);
            }

            var resultObj = Object.Instantiate(result.gameObject, buildData.ConstructorObject.position + Vector3.down * 3f,
                                               Quaternion.identity, buildData.ConstructorObject);

            resultObj.GetComponent <Essence>().Deactivate();

            buildData.ExtractedEssences.Clear();
            buildData.ExtractedEssences.Add(resultObj);
        }