Пример #1
0
    // Spawns an actor and sets up properties.  If provided with a CombatAttackModel it will
    // copy the properties from the model.
    // Otherwies it will attempt to add properties from the owner.
    public static GameObject SpawnCombatActor(UnityEngine.Object objectToSpawn, Vector3 position, GameObject owner = null, CombatAttackModel spawnAttackModel = null)
    {
        GameObject actorGO = Instantiate(objectToSpawn) as GameObject;

        // If this is an attack object we need to set up the attack model
        CombatAttackModel attackCombatModel = actorGO.GetComponent("CombatAttackModel") as CombatAttackModel;

        if (attackCombatModel != null)
        {
            // Set up attack model based off parent.
            attackCombatModel.Owner = owner;

            // Copy properties of parent attack mods if it exists.
            if (spawnAttackModel)
            {
                CopyAttackProperties(spawnAttackModel, ref attackCombatModel);
            }
            // Otherwise if there is an owner try to copy their properties.
            else if (owner != null)
            {
                ColorCombatComponent ownerColorComponent = owner.GetComponent("ColorCombatComponent") as ColorCombatComponent;
                if (ownerColorComponent)
                {
                    CalculateAttackPropertiesFromColorComponent(ref attackCombatModel, ownerColorComponent);
                }
            }
        }

        actorGO.transform.position = position;

        return(actorGO);
    }
Пример #2
0
    public void Awake()
    {
        mColorCombatComponent = gameObject.GetComponent("ColorCombatComponent") as ColorCombatComponent;
        if (mColorCombatComponent == null)
        {
            throw new MissingComponentException("Unable to find ColorCombatComponent");
        }

        mCombatReceiverModel = gameObject.GetComponent("CombatReceiverModel") as CombatReceiverModel;
        if (mCombatReceiverModel == null)
        {
            throw new MissingComponentException("Unable to find CombatReceiverModel");
        }
    }
Пример #3
0
    public void Awake()
    {
        mColorCombatComponent = gameObject.GetComponent("ColorCombatComponent") as ColorCombatComponent;
        if (mColorCombatComponent == null)
        {
            throw new MissingComponentException("Unable to find ColorCombatComponent");
        }

        mCombatReceiverModel = gameObject.GetComponent("CombatReceiverModel") as CombatReceiverModel;
        if (mCombatReceiverModel == null)
        {
            throw new MissingComponentException("Unable to find CombatReceiverModel");
        }
    }
Пример #4
0
    void Awake()
    {
        // Grab the receiver off the object.
        // If no receiver then this object will not have attacks enacted upon it.
        mCombatReceiverModel = gameObject.GetComponent("CombatReceiverModel") as CombatReceiverModel;
        if (mCombatReceiverModel == null)
        {
            throw new MissingComponentException("Unable to find CombatAttackModel.  Spawning a default.");
        }

        mCombatReceiverModel.HealthPoints = mCombatReceiverModel.InitialHealthPoints;
        if (renderer && renderer.material)
        {
            renderer.material.color = mCombatReceiverModel.BaseColor;
            ColorCombatComponent colorComp = GetComponent("ColorCombatComponent") as ColorCombatComponent;
            if (colorComp)
            {
                colorComp.SetColor(mCombatReceiverModel.BaseColor);
            }
        }
    }
Пример #5
0
 private static void CalculateAttackPropertiesFromColorComponent(ref CombatAttackModel attackCombatModel, ColorCombatComponent ownerColorComponent)
 {
     attackCombatModel.BulletSpeedScale		=	ownerColorComponent.GetBulletSpeedScale();
     attackCombatModel.DamageScale 			=	ownerColorComponent.GetDamageScale();
     attackCombatModel.BulletSizeScale 		=	ownerColorComponent.GetBulletSizeScale();
     attackCombatModel.BulletMassScale 		=	ownerColorComponent.GetBulletMassScale();
     attackCombatModel.ExplosionScale		=	ownerColorComponent.GetExplosionSizeScale();
     attackCombatModel.HealthLossRateScale	=	ownerColorComponent.GetHealthLossRateScale();
 }
Пример #6
0
 private static void CalculateAttackPropertiesFromColorComponent(ref CombatAttackModel attackCombatModel, ColorCombatComponent ownerColorComponent)
 {
     attackCombatModel.BulletSpeedScale    = ownerColorComponent.GetBulletSpeedScale();
     attackCombatModel.DamageScale         = ownerColorComponent.GetDamageScale();
     attackCombatModel.BulletSizeScale     = ownerColorComponent.GetBulletSizeScale();
     attackCombatModel.BulletMassScale     = ownerColorComponent.GetBulletMassScale();
     attackCombatModel.ExplosionScale      = ownerColorComponent.GetExplosionSizeScale();
     attackCombatModel.HealthLossRateScale = ownerColorComponent.GetHealthLossRateScale();
 }