示例#1
0
    public CreatureLimb LoadLimb(int index)
    {
        CreatureLimb organ  = new CreatureLimb();
        CreatureLimb source = limbPrototypes[index];
        CombatAction act;

        organ.name                    = source.name;
        organ.prototypeIndex          = source.prototypeIndex;
        organ.limbType                = source.limbType;
        organ.animationControllerName = source.animationControllerName;
        organ.appendageOffsets        = source.appendageOffsets;
        organ.animations              = source.animations;

        //create combat action for the limb
        for (int i = 0; i < source.combatActions.Count; i++)
        {
            act                    = new CombatAction();
            act.limb               = organ;
            act.name               = source.combatActions[i].name;
            act.range              = source.combatActions[i].range;
            act.damage             = source.combatActions[i].damage;
            act.windupDuration     = source.combatActions[i].windupDuration;
            act.attackDuration     = source.combatActions[i].attackDuration;
            act.cooldownDuration   = source.combatActions[i].cooldownDuration;
            act.windupAnimation    = source.combatActions[i].windupAnimation;
            act.attackAnimation    = source.combatActions[i].attackAnimation;
            act.backswingAnimation = source.combatActions[i].backswingAnimation;
            organ.combatActions.Add(act);
        }
        return(organ);
    }
示例#2
0
    private void readOrganLimbNode(XmlProcessor xml)
    {
        string       node;
        CreatureLimb limb = new CreatureLimb();

        //Get Attributes
        limb.name     = "default";
        limb.limbType = "none";
        limb.animationControllerName = "none";

        XmlAttribute attribute = xml.getNextAttribute();

        while (attribute.name != "")
        {
            switch (attribute.name)
            {
            case "name":
                limb.name = attribute.value;
                break;

            case "limbType":
                limb.limbType = attribute.value;
                break;

            case "animationControllerName":
                limb.animationControllerName = attribute.value;
                break;
            }
            attribute = xml.getNextAttribute();
        }

        //Get Subnodes
        node = xml.getNextNode();
        while (node != "/OrganLimbNode")
        {
            switch (node)
            {
            case "OffsetNode":
                limb.appendageOffsets.Add(readOffsetNode(xml));
                break;

            case "AnimationNode":
                limb.animations.Add(readAnimationNode(xml));
                break;

            case "ActionNode":
                limb.combatActions.Add(readActionNode(xml));
                break;
            }
            node = xml.getNextNode();
        }
        limb.prototypeIndex = limbPrototypes.Count;
        limbPrototypes.Add(limb);
    }
示例#3
0
    public void AttachLimb(CreatureBodySegment segment, CreatureLimb limb, Vector3 offset)
    {
        limb.offset = offset;
        GameObject limbObject = Instantiate(Resources.Load <GameObject>("Prefabs/Characters/CreatureDisplayNode"));

        limbObject.transform.parent = segment.obj.transform;
        limbObject.GetComponent <CreatureDisplayNode>().root = limb;
        limbObject.GetComponent <SpriteRenderer>().transform.localPosition = offset;
        limbObject.GetComponent <Animator>().runtimeAnimatorController     = Resources.Load <RuntimeAnimatorController>(limb.animationControllerName);
        limb.obj  = limbObject;
        limb.root = segment.root;
        segment.limbs.Add(limb);
    }
示例#4
0
    public void AttachAppendage(CreatureLimb organ, CreatureAppendage appendage)
    {
        GameObject obj;
        Transform  display = organ.root.display;

        obj = Instantiate(Resources.Load <GameObject>("Prefabs/Characters/CreatureDisplayNode"));
        obj.transform.parent = organ.obj.transform;
        obj.GetComponent <SpriteRenderer>().transform.position  = new Vector3(display.transform.position.x + organ.offset.x, display.transform.position.y + organ.offset.y, organ.offset.z);
        obj.GetComponent <Animator>().runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>(appendage.animationControllerName);
        for (int i = 0; i < appendage.combatActions.Count; i++)
        {
            appendage.combatActions[i].limb = organ;
        }
        appendage.obj    = obj;
        appendage.root   = organ.root;
        appendage.offset = organ.appendageOffsets[0];
        organ.appendage  = appendage;
    }