예제 #1
0
    public void PowerByPressSystem()
    {
        var contexts = new Contexts();
        var power    = new SlingshotShotPowerSystem(contexts);

        var slingshotDesc = new SlingshotDescription();

        slingshotDesc.MaxPower     = 10;
        slingshotDesc.MinPower     = 0;
        slingshotDesc.MaxPowerTime = 2;
        contexts.game.SetSlingshotDescription(slingshotDesc);

        //simulate right press
        contexts.input.isRightMousePress = true;
        contexts.input.rightMousePressEntity.AddTime(10); //time is Time.realtimeSinceStartup

        //left mouse click
        var input = contexts.input.CreateEntity();

        input.isClick = true;
        input.AddTime(11);

        Assert.IsFalse(contexts.game.slingshotDescriptionEntity.hasShotPower);

        power.Execute();

        Assert.IsTrue(contexts.game.slingshotDescriptionEntity.hasShotPower);
        Assert.AreEqual(5, contexts.game.slingshotDescriptionEntity.shotPower.value);
    }
예제 #2
0
    public void ReplaceSlingshotDescription(SlingshotDescription newValue)
    {
        var index     = GameComponentsLookup.SlingshotDescription;
        var component = CreateComponent <SlingshotDescriptionComponent>(index);

        component.value = newValue;
        ReplaceComponent(index, component);
    }
예제 #3
0
    public GameEntity SetSlingshotDescription(SlingshotDescription newValue)
    {
        if (hasSlingshotDescription)
        {
            throw new Entitas.EntitasException("Could not set SlingshotDescription!\n" + this + " already has an entity with SlingshotDescriptionComponent!",
                                               "You should check if the context already has a slingshotDescriptionEntity before setting it or use context.ReplaceSlingshotDescription().");
        }
        var entity = CreateEntity();

        entity.AddSlingshotDescription(newValue);
        return(entity);
    }
예제 #4
0
    public void ReplaceSlingshotDescription(SlingshotDescription newValue)
    {
        var entity = slingshotDescriptionEntity;

        if (entity == null)
        {
            entity = SetSlingshotDescription(newValue);
        }
        else
        {
            entity.ReplaceSlingshotDescription(newValue);
        }
    }