Magic_Game/src/core/ActionGroup.h

151 lines
3.0 KiB
C
Raw Normal View History

// Copyright (c) 2016-2018 Easy2D - Nomango
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
#include "Action.hpp"
namespace easy2d
{
// ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
class Loop
: public Action
{
public:
explicit Loop(
ActionPtr const& action, /* ִ<><D6B4>ѭ<EFBFBD><D1AD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD> */
2019-02-01 23:12:57 +08:00
int times = -1 /* ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
);
virtual ~Loop();
// <20><>ȡ<EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-01-26 17:18:31 +08:00
ActionPtr Clone() const override;
// <20><>ȡ<EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ĵ<EFBFBD>ת
2019-01-26 17:18:31 +08:00
ActionPtr Reverse() const override;
// <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>
2019-01-26 17:18:31 +08:00
void Reset() override;
2019-01-26 17:18:31 +08:00
bool IsRunning() override;
2018-11-15 23:40:13 +08:00
protected:
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-01-26 17:18:31 +08:00
void Init(Node* target) override;
// <20><><EFBFBD><EFBFBD><C2B6><EFBFBD>
2019-01-26 17:18:31 +08:00
void Update(Node* target, Duration dt) override;
protected:
ActionPtr action_;
int times_;
int total_times_;
};
// ˳<><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
class Sequence
: public Action
{
public:
Sequence();
explicit Sequence(
Array<ActionPtr> const& actions /* <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD> */
);
virtual ~Sequence();
// <20>ڽ<EFBFBD>β<EFBFBD><CEB2><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>
void Add(
ActionPtr const& action
);
// <20>ڽ<EFBFBD>β<EFBFBD><CEB2><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void Add(
Array<ActionPtr> const& actions /* <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD> */
);
// <20><>ȡ<EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-01-26 17:18:31 +08:00
ActionPtr Clone() const override;
// <20><>ȡ<EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ĵ<EFBFBD>ת
2019-01-26 17:18:31 +08:00
ActionPtr Reverse() const override;
// <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>
2019-01-26 17:18:31 +08:00
void Reset() override;
protected:
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-01-26 17:18:31 +08:00
void Init(Node* target) override;
// <20><><EFBFBD><EFBFBD><C2B6><EFBFBD>
2019-01-26 17:18:31 +08:00
void Update(Node* target, Duration dt) override;
protected:
UINT action_index_;
Array<ActionPtr> actions_;
};
// ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
class Spawn
: public Action
{
public:
Spawn();
explicit Spawn(
Array<ActionPtr> const& actions /* <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD> */
);
virtual ~Spawn();
// <20>ڽ<EFBFBD>β<EFBFBD><CEB2><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>
void Add(
ActionPtr const& action
);
// <20>ڽ<EFBFBD>β<EFBFBD><CEB2><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void Add(
Array<ActionPtr> const& actions /* <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD> */
);
// <20><>ȡ<EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-01-26 17:18:31 +08:00
ActionPtr Clone() const override;
// <20><>ȡ<EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ĵ<EFBFBD>ת
virtual ActionPtr Reverse() const;
// <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>
2019-01-26 17:18:31 +08:00
void Reset() override;
protected:
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-01-26 17:18:31 +08:00
void Init(Node* target) override;
// <20><><EFBFBD><EFBFBD><C2B6><EFBFBD>
2019-01-26 17:18:31 +08:00
void Update(Node* target, Duration dt) override;
protected:
Array<ActionPtr> actions_;
};
}